huaxiangsun commented on code in PR #12771:
URL: https://github.com/apache/iceberg/pull/12771#discussion_r2039688419


##########
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:
   Thanks @pvary for review. I will read more to see if the test can be moved 
to TestParquet and if test on the parquet files. 
   As for default, there is a bug in Parquet-mr module with default, 
https://github.com/apache/parquet-java/pull/3189, right now, the default is 
always true which means it cannot be really configured.
   My intention is that:
     1. User can configure default to true, and disable stats for specific 
columns. or
     2. User can configure default to false, enable stats for specific columns.
   



-- 
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

Reply via email to