fix: rebase lambda params after projection schema changes - #24406
Open
shinzoxD wants to merge 1 commit into
Open
fix: rebase lambda params after projection schema changes#24406shinzoxD wants to merge 1 commit into
shinzoxD wants to merge 1 commit into
Conversation
LambdaExpr mixed own-parameter indexes into the outer-batch capture projection. After a projection rewrite grew the input schema, a stale param index such as x@1 became a real input column and evaluation failed with a Field mismatch. Bind own params by name into the captures++params layout instead, and leave nested-lambda params for the inner LambdaExpr to remap. Closes apache#24372
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?
Closes #24372
Rationale for this change
Physical
LambdaVariablebindings are planned in a combinedinput_schema ++ paramsindex space.LambdaExprthen built its outer-batch capture projection from everyColumnandLambdaVariableindex in the body.That is safe only while the input width stays the same as at plan time. After a later rewrite moves the expression across a schema boundary (collapsing consecutive
ProjectionExecs, or pushing a join filter belowNestedLoopJoinExec), a stale param index such asx@1can become a real input column. Evaluation then fails:The two issue reproducers were:
and the
array_filterjoin-filter pushdown case.What changes are included in this PR?
captures ++ used_paramslayout thatLambdaArgument::newalready builds.LambdaExpr.Are these changes tested?
datafusion/physical-expr/src/expressions/lambda.rs, including a regression that a planner-assignedx@1is not treated as an outer-batch capture.array_transform.sltandarray_filter.slt.array_transform,array_filter,array_any_match,array_all,array_any_value,array_first) still pass.Are there any user-facing changes?
No public API change. Queries that previously failed after a projection/join-filter rewrite now return the correct result.