Repository navigation
feat: push down filters with decimal literals - #173
Open
NoahKusaba wants to merge 1 commit into
Open
NoahKusaba wants to merge 1 commit into
NoahKusaba wants to merge 1 commit into
Conversation
Comparisons and IN lists with a Decimal128 literal weren't converted to Iceberg predicates, so filters on decimal columns never skipped files. Convert the literal to an Iceberg decimal with the same value, precision and scale. A literal Iceberg can't hold (a negative scale, or more digits than its precision) isn't converted, and its filter stays with DataFusion. Literals DataFusion can't convert exactly to the column's type already leave a cast on the column, so they aren't pushed down either. Closes apache#73.
NoahKusaba
marked this pull request as ready for review
December 6, 2026 01:07
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.
Which issue does this PR close?
@terbed, you mentioned a draft on #73. I'm happy to fold anything from it into this PR, or to review yours instead if you'd rather open it.
Rationale for this change
scalar_value_to_datumdidn't convertDecimal128literals, so a filter on a decimal column was never passed to Iceberg and couldn't skip data files. Decimal filters are common in analytical queries; TPC-H q6, for one, filters on the decimal columnsl_discountandl_quantity.What changes are included in this PR?
Decimal128literals convert to an Iceberg decimal with the same value, precision and scale. A literal Iceberg can't hold isn't converted, and its filter stays with DataFusion: Arrow allows a negative scale and a value with more digits than its precision, Iceberg neither.Nothing else is needed for the common SQL forms. DataFusion's
unwrap_cast_in_comparisonalready converts an integer, float or narrower decimal literal to the column's type when the result doesn't change, soprice > 1,price > 1.2andprice > CAST('1.2' AS DECIMAL(5, 1))are all pushed down. A literal it can't convert exactly, such asCAST('1.205' AS DECIMAL(10, 3))against aDECIMAL(10, 2)column, leaves a cast on the column and isn't pushed down.The datum is built with
Datum::try_from_bytesand checked withDatum::to, because iceberg-rust'sDatum::decimal_from_mantissais private. A TODO notes the cleanup if it becomes public.Are these changes tested?
Yes.
predicate.rs: the literal conversion (negative values, scale kept as in1.20, the largest 38-digit values, values over their precision, negative scales, NULL), and comparisons andINlists, including anINlist with a value Iceberg can't hold, which isn't pushed down at all.filter_pushdown::decimal_filters_skip_files: a decimal filter matching one of three files opens only that file.decimal_predicate_pushdown.slt: which SQL forms are pushed down, and the rows returned by each comparison,INandNOT INacross five data files, including the largest and smallestDECIMAL(10, 2)andDECIMAL(38, 10)values.The slt uses typed literals for values with seven or more digits before the point. DataFusion casts such float literals to
Decimal128(30, 15)inexactly, soprice = 99999999.99matches no rows whatever the table provider (apache/datafusion#28053).Are there any user-facing changes?
Filters on decimal columns now skip data files. Query results don't change.