API: Fix struct metrics in nested struct evaluator test - #17412
Conversation
`FILE_6` in `TestInclusiveMetricsEvaluator` carried value and null counts for the
`required_address` and `optional_address` structs. Parquet produces metrics for leaf
columns only in `ParquetMetrics.MetricsVisitor.struct` and returns just the concatenation of
its children and never emits a `FieldMetrics` for the struct — so no Parquet file yields
those entries. They made `notNull("optional_address")` appear prunable when in practice it is not
| shouldRead = | ||
| new InclusiveMetricsEvaluator(NESTED_SCHEMA, isNull("optional_address.required_street2")) | ||
| .eval(FILE_6); | ||
| assertThat(shouldRead).as("Should read: optional_address is optional").isTrue(); |
There was a problem hiding this comment.
nit, not related to the change but I think the reason to prune the field 104 and 105 for notNull predicate is a bit different from "optional_address is optional".
Since both are nested within an optional struct, we cannot decide based on schema whether values are nullable or not. The decision is made based on the leaf field metrics (value count = 5 and null count = 5. so all values are null and evaluate to false)
Meant to comment on LINE966, my bad
This is true for Parquet, but do we have anything in the spec which would prevent other file formats fill out these metrics? Shall we enforce this behaviour through the spec, or handle the struct metrics when they exist in the stats correctly? |
FILE_6inTestInclusiveMetricsEvaluatorcarried value and null counts for therequired_addressandoptional_addressstructs. Parquet produces metrics for leaf columns only inParquetMetrics.MetricsVisitor.structand returns just the concatenation of its children and never emits aFieldMetricsfor the struct — so no Parquet file yields those entries. They madenotNull("optional_address")appear prunable when in practice it is notproduces, which excludes struct-level value and null counts.