Repository navigation
Conversation
…e predicate Page-index bounds are built with the table field type but the file's physical literal. When the two differ, e.g. a long field read against INT32 pages written before an int -> long promotion, a double field against FLOAT pages, or a UINT_32 column mapped to long, the bounds never compare with the predicate literal. Inequality and IN predicates treated that as "cannot match" and skipped pages holding matching rows. Keep a page whenever its bound cannot be compared with the literal: the inequality check now treats an incomparable bound as a possible match, and IN uses all(lt) / all(gt) instead of !any(ge) / !any(le).
A page holding both 100 and 3_000_000_000 has a raw signed max below its min, which pins the unsigned column order that a later bound widening has to zero-extend rather than sign-extend.
Page bounds written before an int -> long or float -> double promotion are now widened with Datum::promote_to, so inequality and IN predicates can prune these pages instead of keeping them all. UINT_32 bounds are INT32 bits in unsigned order, so they are zero-extended; if the result has min > max the writer used signed order and the page is kept.
Legacy writers may store NaN page bounds for pages holding other values. Datum compares floats with total_cmp, so such a bound, now also produced by widening FLOAT bounds to double, could prune a matching page. Drop both bounds of a FLOAT or DOUBLE page when either is NaN, so the page might match.
comphead
added a commit
to comphead/iceberg-rust
that referenced
this pull request
Oct 26, 2026
A file written before an int -> long, float -> double, or decimal precision promotion keeps its old physical type, while the predicate is bound to the table type. The row filter cast the literal down to the file's Arrow type, so an out-of-range literal became null and dropped every row, and a double literal was rounded to f32. Cast a numeric column to the table type before comparing instead, as RecordBatchTransformer does for the output. Other columns keep the literal cast. Page-index pruning is left to apache#3507 and apache#3521. Part of apache#3122.
comphead
added a commit
to comphead/iceberg-rust
that referenced
this pull request
Oct 27, 2026
Predicates are bound to the table schema, but the row filter evaluated them on batches in the file's physical types. For a file written before an int -> long, float -> double, or decimal precision promotion, try_cast_literal cast the literal down to the file type, so an out-of-range literal became null and dropped every row, and a double literal was rounded to f32. Convert the filter columns to the table schema with a RecordBatchTransformer, as the reader does for its output, and make try_cast_literal fail instead of returning null. Page-index pruning is left to apache#3507 and apache#3521. Part of apache#3122.
comphead
added a commit
to comphead/iceberg-rust
that referenced
this pull request
Nov 22, 2026
Predicates are bound to the table schema, but the row filter evaluated them on batches in the file's physical types. For a file written before an int -> long, float -> double, or decimal precision promotion, try_cast_literal cast the literal down to the file type, so an out-of-range literal became null and dropped every row, and a double literal was rounded to f32. Convert the filter columns to the table schema with a RecordBatchTransformer, as the reader does for its output, and make try_cast_literal fail instead of returning null. Page-index pruning is left to apache#3507 and apache#3521. Part of apache#3122.
apache#3507 merged with Arrow 60 changes: PageIndexEvaluator::eval takes a RowGroupPageIndex and ColumnIndexBuilder::append takes a nan_count, so the NaN-bound test now builds its page index with PageIndexBuilder. The promoted INT32 and FLOAT tests also cover the inequality operators that apache#3507 added.
rich7420
marked this pull request as ready for review
November 23, 2026 06:13
hcrosse
pushed a commit
to hcrosse/iceberg-rust
that referenced
this pull request
Nov 23, 2026
…che#3540) * fix(reader): keep matching rows when filtering a promoted column Predicates are bound to the table schema, but the row filter evaluated them on batches in the file's physical types. For a file written before an int -> long, float -> double, or decimal precision promotion, try_cast_literal cast the literal down to the file type, so an out-of-range literal became null and dropped every row, and a double literal was rounded to f32. Convert the filter columns to the table schema with a RecordBatchTransformer, as the reader does for its output, and make try_cast_literal fail instead of returning null. Page-index pruning is left to apache#3507 and apache#3521. Part of apache#3122. * test(reader): cover files without field ids and date promotion; name the strict cast Reuse read_once in assert_promoted_reads, read each file with and without a field id, and add a date -> timestamp case. Explain why try_cast_literal sets safe: false. * perf(reader): build the row filter transformer from the filter fields only The transformer converts its whole schema to Arrow on each file's first batch. Give it a schema of the top-level filter fields so that setup no longer grows with the table's width. * fix(reader): build the row filter schema from each leaf's top-level field A filter leaf nested in a struct has no top-level field of its own, so the filter schema missed it and the transformer failed with `field not found` once nested predicates reach the row filter (apache#2906). Take each leaf's top-level field, prune it to the filter leaves, and pass the top-level ids in leaf order. * fix(reader): reject a filter leaf that is not in the scan schema filter_schema skipped a leaf without an accessor in the scan schema, so the converted filter batch had fewer columns than the predicate's column positions, and the predicate panicked with an index out of bounds. Only a task whose predicate was bound to another schema gets there. Fail with DataInvalid instead, as validate_equality_ids does for equality deletes and the row group evaluator does with default options. * fix(spec): return an empty struct from prune_columns for an empty selection PruneColumn::schema unwrapped the visited struct, so selecting nothing panicked before prune_columns reached its fallback to an empty struct. Return the value as is, so the fallback applies. * refactor(reader): simplify the row filter schema and its tests - filter_schema returns only the schema. The transformer's root ids are its top-level fields, and the empty-selection guard is gone now that prune_columns handles it. - Use invalid_data! for the unknown-leaf error, and drop the unused schema id. - try_cast_literal's doc no longer cites Binary and LargeBinary, which now map to one Arrow type. - test_predicate_converter_rejects_lossy_literal_cast reuses apply_predicate_to_batch, which now takes the file's message type and returns the predicate's result. - test_predicate_on_promoted_column keeps one case per promotion. The dropped cases passed or failed together with the kept ones under every mutation of the row filter.
This branch has not been deployed
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.
Note
This PR was stacked on #3507, which has been merged. I merged
maininto this branch, so the diff now shows only this PR's changes. The commit list still shows the #3507 commits.Which issue does this PR close?
What changes are included in this PR?
This implements the widening follow-up agreed in #3507. That PR prevents pruning based on incomparable page-index bounds, such as
INT32bounds read as alongfield after anint->longpromotion. This PR widens supported bounds to the field type so inequality andINpredicates can prune these pages.INT32bounds for alongfield andFLOATbounds for adoublefield are widened withDatum::promote_to, added in #3483.UINT_32bounds are stored asINT32bit patterns ordered as unsigned values. The column descriptor’s sort order identifies unsigned bounds, which are zero-extended tolong. If this producesmin > max, as can happen with bounds written in signed order, both bounds are discarded.FLOATorDOUBLEbound is NaN, both bounds are discarded. Legacy writers may store NaN bounds for pages that also contain other values, as documented in the Parquet specification.Datumusestotal_cmpfor floating-point comparisons, so trusting these bounds can prune matching pages. Widening exposes promoteddoublefields to this risk too. #3502 added a related NaN guard for row-group inequality pruning.Discarding bounds prevents pruning based on those bounds; null-count checks and other predicates still apply. Bounds that remain incomparable, such as
INT32bounds for atimestampfield, retain the conservative fallback from #3507.Are these changes tested?
Yes. Evaluator tests in
page_index_evaluator.rsuse metadata from real Parquet files and assert exact row selections. The NaN cases substitute synthetic column indexes.longfield overINT32pages:<,<=,>,>=,<with a literal abovei32::MAX,>withi32::MAX, and two-valueIN.doublefield overFLOATpages:<,<=,>,>=, and two-valueIN.longfield overUINT_32pages, including a value abovei32::MAXand a page mixing100and3_000_000_000:=,>,<, andIN.FLOATpages read as nativefloator promoteddouble, andDOUBLEpages read as nativedouble: pages with a NaN minimum or maximum are kept for=,<,>, and two-valueIN.timestampfield overINT32pages: the existing fallback test checks that every page is kept for<,<=,>,>=,=, andIN.Helper tests also verify that signed-order
UINT_32bounds are discarded, correctly ordered bounds are widened, and both floating-point bounds are discarded if either is NaN while finite bounds are preserved.After I merged
main, mutation checks confirmed that sign-extendingUINT_32bounds, removing themin > maxcheck, and removing the NaN check each cause at least one test to fail.cargo test -p iceberg --lib expr::visitorsandcargo test -p iceberg --lib arrowpassed, as didcargo fmt --all -- --checkandcargo clippy -p iceberg --all-targets --all-features -- -D warnings.AI Disclosure
Drafted with Claude Code and reviewed with Codex. Review focus: whether zero-extension and the signed-order check are correct for
UINT_32columns, and whether discarding both bounds when either is NaN is conservative across predicates.