huaxiangsun commented on code in PR #12771: URL: https://github.com/apache/iceberg/pull/12771#discussion_r2043338512
########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/data/TestSparkParquetWriter.java: ########## @@ -151,4 +152,27 @@ public void testFpp() throws IOException, NoSuchFieldException, IllegalAccessExc assertThat(fpp).isEqualTo(0.05); } } + + @Test + public void testColumnStatsEnabled() + throws IOException, NoSuchFieldException, IllegalAccessException { + File testFile = File.createTempFile("junit", null, temp.toFile()); + try (FileAppender<InternalRow> writer = + Parquet.write(Files.localOutput(testFile)) + .schema(SCHEMA) + .set(PARQUET_COLUMN_STATS_ENABLED_PREFIX + "id_long", "false") + .createWriterFunc( + msgType -> + SparkParquetWriters.buildWriter(SparkSchemaUtil.convert(SCHEMA), msgType)) + .build()) { + // Using reflection to access the private 'props' field in ParquetWriter + Field propsField = writer.getClass().getDeclaredField("props"); + propsField.setAccessible(true); + ParquetProperties props = (ParquetProperties) propsField.get(writer); + MessageType parquetSchema = ParquetSchemaUtil.convert(SCHEMA, "test"); + ColumnDescriptor idlDescriptor = parquetSchema.getColumnDescription(new String[] {"id_long"}); + // Default statisticsEnabled should be true and for column id_long, it is disabled. + assertThat(props.getStatisticsEnabled(idlDescriptor)).isEqualTo(false); + } + } Review Comment: I added a unitest case in TestParquet, going to remove the test in Spark. Will upload the diff later with the documentation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org