aihuaxu commented on code in PR #14081: URL: https://github.com/apache/iceberg/pull/14081#discussion_r2349896296
########## parquet/src/main/java/org/apache/iceberg/parquet/ParquetMetricsRowGroupFilter.java: ########## @@ -157,8 +157,10 @@ public <T> Boolean notNull(BoundReference<T> ref) { // When filtering nested types notNull() is implicit filter passed even though complex // filters aren't pushed down in Parquet. Leave all nested column type filters to be - // evaluated post scan. - if (schema.findType(id) instanceof Type.NestedType) { + // evaluated post scan. Variant types also need to be evaluated post scan to access + // shredded statistics. Review Comment: +1 on this. ########## data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java: ########## @@ -988,6 +993,97 @@ public void testTransformFilter() { .isTrue(); } + @TestTemplate + public void testVariantFilterNotNull() throws IOException { + assumeThat(format).isEqualTo(FileFormat.PARQUET); + + Schema variantSchema = + new Schema( + required(1, "id", IntegerType.get()), + optional(2, "variant_field", Types.VariantType.get())); + + File parquetFile = new File(tempDir, "test-variant" + System.nanoTime()); + + OutputFile outFile = Files.localOutput(parquetFile); + try (FileAppender<GenericRecord> appender = + Parquet.write(outFile) + .schema(variantSchema) + .createWriterFunc(GenericParquetWriter::create) + .build()) { + + for (int i = 0; i < 10; i++) { + GenericRecord record = GenericRecord.create(variantSchema); + record.setField("id", i); + + if (i % 2 == 0) { + VariantMetadata metadata = Variants.metadata("field"); + ShreddedObject obj = Variants.object(metadata); + obj.put("field", Variants.of("value" + i)); + Variant variant = Variant.of(metadata, obj); + record.setField("variant_field", variant); + } + + appender.add(record); + } + } Review Comment: +1. Seems we don't need to write to the files. -- 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