fix: avoid unsafe set rewrites for compound IN lists - #24952
Draft
bvolpato wants to merge 1 commit into
Draft
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24952 +/- ##
========================================
Coverage 81.61% 81.61%
========================================
Files 1124 1124
Lines 411978 412151 +173
Branches 411978 412151 +173
========================================
+ Hits 336236 336388 +152
- Misses 55936 55941 +5
- Partials 19806 19822 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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?
Related to #24258. This covers runtime operands, floating-point literals, and volatile expressions in compound IN-list rewrites. The NULL-semantics changes in that PR remain separate.
Rationale for this change
The optimizer performs set intersection and difference using expression equality. Different expressions can evaluate to the same value, so these rewrites can remove matching rows even when every column is non-nullable:
The query should return
1; the rewrite produces an empty intersection and returns no rows. Structural comparison also distinguishes positive and negative floating-point zero. Deduplicating volatile operands can change how many times they are evaluated.What changes are included in this PR?
predicates.slt.What is the testing strategy for this PR?
35f58f53cde2f634c21f6370e385cf1d7e9bc55cand pass with the fix.cargo test --locked -p datafusion-optimizer --lib: 777 passed.cargo fmt --all -- --checkandgit diff --checkpassed.predicates.slt.Are there any user-facing changes?
Affected compound IN predicates retain matching rows and preserve volatile expression evaluations. No public API changes.
Downsides
Queries excluded by the new guards may perform more comparisons because the optimizer retains their original predicates.