Repository navigation
fix(physical-expr): treat null-propagating comparisons with a NULL operand as NULL in CaseExpr::nullable - #27454
Open
Jaden-Varkey wants to merge 1 commit into
Open
Jaden-Varkey wants to merge 1 commit into
Jaden-Varkey wants to merge 1 commit into
Conversation
…erand as NULL in CaseExpr::nullable Closes apache#26284
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?
CASE WHEN a < b THEN a ELSE ... END#26284.Rationale for this change
SELECT DISTINCT CASE WHEN a < b THEN a ELSE 1 END FROM n(and thesum/UNIONvariants in the issue) fails with "Physical input schema should be the same as the one converted from logical input schema" because the logical and physical planners disagree on the CASE's nullability.The logical side (
predicate_bounds::is_null) knowsNULL < bis always NULL, so theTHEN abranch is never taken whenais NULL and the result is non-nullable. The physicalevaluate_predicatecan't constant-foldNULL < b(it still referencesb) and falls back toANY_TRUTH_VALUE, so the result is nullable. Existing tests only used predicates that constant-fold (a > 1,a IS NOT NULL).What changes are included in this PR?
evaluate_predicatenow returnsUNKNOWNwhen the predicate is certainly NULL: a NULL literal, areturns_null_on_null()binary op with a certainly-NULL operand, orNOT/-/CASTof one. This mirrors the logicalis_null, and follows the same sync approach asunwrap_certainly_null_expr(#23844).What is the testing strategy for this PR?
test_case_expression_nullability_with_column_comparisonincase.rs: non-nullable fora < b,a + 1 < b,CAST(a) < CAST(b); still nullable forIS DISTINCT FROManda < b OR b IS NULL.case.slt.Both fail on
mainand pass with the fix.Are there any user-facing changes?
No, other than those queries no longer erroring.
AI-assisted (Claude). I've reviewed the change.