Support predicate subqueries in projections - #24972
Conversation
0f76189 to
edd9e50
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24972 +/- ##
==========================================
- Coverage 81.91% 81.91% -0.01%
==========================================
Files 1134 1134
Lines 425637 425752 +115
Branches 425637 425752 +115
==========================================
+ Hits 348654 348743 +89
- Misses 56302 56308 +6
- Partials 20681 20701 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fc6e643 to
707d9df
Compare
|
Very cool! I'll take a look |
kosiew
left a comment
There was a problem hiding this comment.
Thanks for working on this. The projection rewrite and three-valued IN/NOT IN handling look good to me. I just have one non-blocking suggestion around correlated NOT IN coverage.
| true true | ||
|
|
||
| # Correlated IN distinguishes a match, a miss, a NULL-containing result, | ||
| # and an empty result independently for each outer row. |
There was a problem hiding this comment.
Could we also add correlated NOT IN execution cases here? It would be useful to cover an inner NULL, an empty correlated result, and a NULL outer value. The current correlated test covers IN, while these cases would directly exercise the projection-specific not(result) path and make sure the per-row NULL and non-empty marks behave correctly.
There was a problem hiding this comment.
Added correlated NOT IN execution coverage for all requested cases: an inner NULL, an empty correlated result, and a NULL outer value, along with match and miss controls. The focused subquery_projection SLT passes locally.
|
🚀 |
Which issue does this PR close?
Rationale for this change
Predicate subqueries such as
EXISTS,IN, andNOT INare valid scalar expressions in aSELECTlist, but DataFusion currently only decorrelates them when they appear in filters. Projection queries therefore reach physical planning with an unsupported logical subquery expression.This continues the work from the now-closed stale #23039 and covers multiple and correlated projection subqueries as well as SQL null semantics.
What changes are included in this PR?
EXISTS,NOT EXISTS,IN, andNOT INexpressions inside projections into mark joinsIN/NOT INvalues with SQL three-valued logic by tracking matches, nulls, and empty subqueriesWhat is the testing strategy for this PR?
Optimizer plan tests cover projected
INrewriting. New SQLLogicTest cases cover uncorrelated and correlatedEXISTS/IN, multiple subqueries in one projection, empty inputs, null inputs, andNOT INthree-valued logic.Locally validated with:
cargo test -p datafusion-optimizer decorrelate_predicate_subquery(53 passed)cargo test -p datafusion-sqllogictest --test sqllogictests -- subquery_projectioncargo clippy -p datafusion-optimizer --all-targets --all-features -- -D warningscargo fmt --all -- --checkAre there any user-facing changes?
Yes. Predicate subqueries can now be evaluated as projected scalar expressions. There are no public API changes.