uros-b commented on code in PR #17365:
URL: https://github.com/apache/iceberg/pull/17365#discussion_r3652162902
##########
parquet/src/test/java/org/apache/iceberg/parquet/TestParquet.java:
##########
@@ -288,6 +288,54 @@ public void testColumnStatisticsEnabled() throws Exception
{
}
}
+ @Test
+ public void testMultipleColumnsStatisticsDisabled() throws Exception {
+ Schema schema =
+ new Schema(
+ optional(1, "int_field", IntegerType.get()),
+ optional(2, "string_field", Types.StringType.get()),
+ optional(3, "long_field", Types.LongType.get()));
+
+ File file = createTempFile(temp);
+
+ List<GenericData.Record> records = Lists.newArrayListWithCapacity(5);
+ org.apache.avro.Schema avroSchema =
AvroSchemaUtil.convert(schema.asStruct());
+ for (int i = 1; i <= 5; i++) {
+ GenericData.Record record = new GenericData.Record(avroSchema);
+ record.put("int_field", i);
+ record.put("string_field", "test");
+ record.put("long_field", (long) i);
+ records.add(record);
+ }
+
+ write(
+ file,
+ schema,
+ ImmutableMap.<String, String>builder()
+ .put(PARQUET_COLUMN_STATS_ENABLED_PREFIX + "int_field", "false")
+ .put(PARQUET_COLUMN_STATS_ENABLED_PREFIX + "string_field", "false")
+ .buildOrThrow(),
+ ParquetAvroWriter::buildWriter,
+ records.toArray(new GenericData.Record[] {}));
+
+ InputFile inputFile = Files.localInput(file);
+
+ try (ParquetFileReader reader =
ParquetFileReader.open(ParquetIO.file(inputFile))) {
+ for (BlockMetaData block : reader.getFooter().getBlocks()) {
+ for (ColumnChunkMetaData column : block.getColumns()) {
+ boolean emptyStats = column.getStatistics().isEmpty();
+ if (column.getPath().toDotString().equals("int_field")) {
+ assertThat(emptyStats).as("int_field statistics are
disabled").isTrue();
+ } else if (column.getPath().toDotString().equals("string_field")) {
+ assertThat(emptyStats).as("string_field statistics are
disabled").isTrue();
+ } else if (column.getPath().toDotString().equals("long_field")) {
+ assertThat(emptyStats).as("long_field has statistics").isFalse();
+ }
+ }
+ }
+ }
+ }
+
Review Comment:
The "all columns disabled" scenario is absent. That case (every column in
the schema suppressed) is the one most directly reported in #15347 and was
explicitly covered by the now-closed #16639; adding it alongside the
"some-disabled, one-kept" case would make this a complete guard rather than a
subset.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]