Fix CASE evaluation for custom column expressions - #24484
Open
Hasnaathussain wants to merge 1 commit into
Open
Conversation
Signed-off-by: Hasnaat Hussain <hasnaat.hussain.2@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.
Which issue does this PR close?
Rationale for this change
A custom column-like
PhysicalExprcan read an input column without downcasting to DataFusion's concreteColumntype. CASE's internal projection then misses that dependency and evaluates the expression against a zero-column batch, causing a runtime error.What changes are included in this PR?
CASE projection now falls back to the original input batch when it encounters an unknown leaf expression. Known columns, lambda variables, literals, and composite expressions keep the existing projection optimization.
The regression test uses a custom
PhysicalExprthat wraps a column without exposing a concreteColumnnode.Are these changes tested?
Yes:
cargo fmt --all -- --checkcargo clippy -p datafusion-physical-expr --all-targets --all-features -- -D warningscargo test -p datafusion-physical-expr expressions::case::tests(36 passed)cargo test -p datafusion-physical-expr(1,596 passed, 2 ignored; 13 doctests passed)The extended workspace command also reached the existing TPC-H q15 unparser failure. Its multi-statement error reproduces unchanged at the base commit, outside this patch.
Are there any user-facing changes?
Custom physical expressions can now be evaluated correctly inside searched CASE expressions. There is no public API change.