Parquet: Fix incorrect pruning for nested fields in optional structs - #18069
Open
szehon-ho wants to merge 1 commit into
Open
Parquet: Fix incorrect pruning for nested fields in optional structs#18069szehon-ho wants to merge 1 commit into
szehon-ho wants to merge 1 commit into
Conversation
szehon-ho
force-pushed
the
codex/parquet-nested-double-metrics-test
branch
from
September 11, 2026 22:13
694e48e to
f7e9f11
Compare
szehon-ho
force-pushed
the
codex/parquet-nested-double-metrics-test
branch
2 times, most recently
from
September 11, 2026 22:24
c9205fe to
0506aa4
Compare
szehon-ho
force-pushed
the
codex/parquet-nested-double-metrics-test
branch
from
September 11, 2026 23:05
0506aa4 to
98e0663
Compare
Propagate null counts from optional Parquet writers to custom metrics produced by descendant fields. This prevents incorrect file pruning for nested float, double, geometry, and geography fields beneath a null optional parent. Add focused writer-metrics coverage for all affected types and Spark SQL coverage for the resulting nested double filter. Generated-by: Codex
szehon-ho
force-pushed
the
codex/parquet-nested-double-metrics-test
branch
from
September 11, 2026 23:19
98e0663 to
3950b47
Compare
szehon-ho
marked this pull request as ready for review
September 11, 2026 23:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Broken case
An optional struct may be null even when one of its nested fields is required. In that case, dereferencing the nested field produces null.
For example, Spark writes both of these rows to one Parquet file:
This query must return
id = 0becausestats.measurementis null whenstatsis null:Before this fix, Spark returned no rows. The double writer reported
value_count = 1andnull_value_count = 0forstats.measurement, instead of2and1. Iceberg therefore concluded that the file could not contain a null measurement and incorrectly pruned it.Cause and fix
Float and double maintain writer-side metrics to exclude NaN values from bounds. Geometry and geography also maintain writer-side metrics for average value sizes. These metrics replace the Parquet footer metrics, but null optional parents were not propagated to metrics produced by descendant writers.
This change propagates an optional parent's null count to every descendant custom metric while preserving bounds, NaN counts, original types, and average value sizes. The existing nested string test continues to cover the unaffected footer-metrics path.
Testing
:iceberg-parquet:test --tests "org.apache.iceberg.parquet.TestParquetValueWriters"passes, covering float, double, geometry, and geography beneath a null optional parent, plus the existing direct geospatial case.[]instead of[[0]].:iceberg-parquet:spotlessJavaCheckand:iceberg-spark:iceberg-spark-4.1_2.13:spotlessJavaCheckpass.AI Disclosure