Push down decimal Add/Sub to Vortex in DataFusion filters and projections#8936
Draft
mhk197 wants to merge 3 commits into
Draft
Push down decimal Add/Sub to Vortex in DataFusion filters and projections#8936mhk197 wants to merge 3 commits into
mhk197 wants to merge 3 commits into
Conversation
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.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.
Pushes decimal Add/Sub filters and projections into the Vortex scan, and stops accepting decimal arithmetic pushdowns that Vortex cannot execute.
Problem
DataFusion evaluates decimal
+/-with the arrownumerickernels: mismatched operands are rescaled inside the kernel, and the result type follows the Hive ruleVortex's decimal kernels (#8724) instead require both operands to share one decimal dtype and widen the result by a carry digit, capped only at Vortex's max precision (76).
The filter pushdown path accepted any decimal arithmetic on structural grounds and reported
PushedDown::Yes, so DataFusion dropped the predicate from its own plan and the query failed at scan time — a dtype-mismatch error for mixed operand dtypes and forDecimal128(38, s)operands (where arrow saturates at 38 but Vortex widens to 39), ornot yet supportedfor decimal Mul/Div. The projection path refused all decimal arithmetic outright.Approach
Vortex already ships the operand-alignment machinery:
Binary::coerce_argscomputes the least supertype of its operands — for decimals exactly the(p - 1, s)dtype arrow rescales to internally — but thecoerce_expressionpass had no callers. This PR wires it in:make_vortex_predicateandsplit_projectionrun converted expressions throughcoerce_expressionagainst the scan's dtype scope (the per-file dtype in the opener, the data source dtype in v2). A pushed-down decimal Add/Sub then reproduces DataFusion's result type and values exactly: the operand casts perform the same checked power-of-ten rescale as the arrow kernel, and Vortex's carry-digit rule lands on the same(p, s).coerce_expressioninserts casts on nullability-only differences, which would otherwise wrap literals in ordinary predicates and could interfere with pruning. IfBinary::coerce_argsis later refined to preserve per-child nullability, the pass could run unconditionally.ExpressionConvertor::convertis unchanged; alignment happens once on the finished expression tree.Pushdown is rejected — the filter stays in DataFusion's
FilterExec, or the projection in the source's post-scan projector — when the semantics diverge or the kernel does not exist:Decimal128(38, s)operands), where arrow saturates the result precision while Vortex widens it,The blanket decimal-arithmetic exclusion in
split_projectionnarrows to the same rule, so decimal Add/Sub projections push down too whenprojection_pushdownis enabled.