fix: preserve null semantics in expression simplification - #24258
Open
fzlzjerry wants to merge 3 commits into
Open
fix: preserve null semantics in expression simplification#24258fzlzjerry wants to merge 3 commits into
fzlzjerry wants to merge 3 commits into
Conversation
Contributor
|
I'll try and review it later today |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24258 +/- ##
========================================
Coverage 81.01% 81.01%
========================================
Files 1106 1106
Lines 383974 384228 +254
Branches 383974 384228 +254
========================================
+ Hits 311085 311297 +212
- Misses 54554 54577 +23
- Partials 18335 18354 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Contributor
|
@neilconway thanks for the heads up, I'll try and do a pass on all three tonight/tomorrow morning (UK time). |
Author
|
Thanks for flagging these. I compared the scopes:
I'll keep the current comparison available for the review pass, then promptly rebase and drop whichever overlapping implementation the maintainers decide not to use. |
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
Several expression simplifications erase SQL NULL semantics. For nullable inputs, identities such as
power(a, 0),log(a, 1), andi XOR ican return constants instead of NULL. Set algebra overINexpressions and thearray_hastoINrewrite can similarly change NULL or false results.What changes are included in this PR?
IN/NOT INset operations unchanged when list items may be NULL, and preserve the nullable branch when an otherwise safe operation becomes a constant.array_hastoINwhen a nullable array element would change the result, while retaining the safe same-expression case.Are these changes tested?
Yes. The following checks pass:
./dev/rust_lint.shcargo test --profile=ci -p datafusion-functions -p datafusion-functions-nested -p datafusion-optimizer --libcargo test --profile=ci --test sqllogictestsRUST_BACKTRACE=1 prlimit --nofile=65536:65536 -- cargo test --profile ci --exclude datafusion-examples --exclude datafusion-benchmarks --exclude datafusion-cli --workspace --lib --tests --bins --features avro,json,backtrace,extended_tests,recursive_protection,parquet_encryptionAre there any user-facing changes?
Yes. Expressions involving nullable inputs now retain their SQL three-valued-logic results instead of being simplified to incorrect constants. There are no public API changes.