Repository navigation
Widen decimal literal precision in scan filters - #4348
Merged
Merged
Conversation
A decimal filter literal with more digits than the column, such as amt < 1000.00 on decimal(5, 2), failed with ArrowInvalid because the Arrow literal took the column's precision. Widen the literal's precision to fit its digits and keep the column's scale, so the comparison is by value. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
Fokko
approved these changes
Nov 11, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Thanks for fixing this @rahulsmahadev 🙌
rahulsmahadev
added a commit
to rahulsmahadev/iceberg-python
that referenced
this pull request
Nov 11, 2026
Resolve the import conflict in tests/io/test_pyarrow.py with apache#4348. Co-authored-by: Isaac <no-reply@databricks.com>
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.
Rationale for this change
A decimal filter literal with more digits than the column's precision makes the scan fail, even though the filter is valid. Here
amtisdecimal(5, 2), so its largest value is 999.99:!=,INandNOT INwith such a literal fail the same way. PyIceberg builds the Arrow literal with the column's type,decimal128(5, 2), which cannot hold1000.00. Java compares by value here: itsDecimalLiteral.tokeeps the literal as is.This change gives the Arrow literal of a decimal column a precision wide enough for its digits (
decimal128(6, 2)here) and keeps the column's scale, for comparisons and forIN/NOT IN. When the literal fits, the Arrow type is unchanged.Related to #4203 / #4210, which handle a column widened by schema evolution (old files keep the narrower type). This PR covers a literal wider than the table's own column type, which #4210 does not change. The two do not conflict: #4210 changes how the file-level filter is bound, this PR changes the Arrow type of decimal literals.
Are these changes tested?
Yes. Both new tests in
tests/io/test_pyarrow.pyfail with theArrowInvalidabove without the fix:test_decimal_literal_wider_than_column_to_pyarrowconverts<,!=,INandNOT INon adecimal(5, 2)column and evaluates them on an Arrow table.test_row_filter_decimal_literal_wider_than_columnscans an in-memory catalog table withamt < 1000.00,amt > -1000.00,amt IN (1.25, 1000.00)andamt < 50.00(a literal that fits). A NULL row in the table matches none of them.Are there any user-facing changes?
Bug fix only: a decimal literal wider than the column's precision no longer makes the scan raise
ArrowInvalid. No API changes.This pull request and its description were written by Isaac.