Support predicate subqueries in projections - #24972
Open
osipovartem wants to merge 3 commits into
Open
Conversation
osipovartem
force-pushed
the
upstream-projection-subquery-expressions
branch
from
September 6, 2026 09:57
0f76189 to
edd9e50
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24972 +/- ##
==========================================
- Coverage 81.67% 81.67% -0.01%
==========================================
Files 1126 1126
Lines 414842 414957 +115
Branches 414842 414957 +115
==========================================
+ Hits 338841 338923 +82
- Misses 56070 56080 +10
- Partials 19931 19954 +23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
osipovartem
force-pushed
the
upstream-projection-subquery-expressions
branch
from
September 6, 2026 16:39
fc6e643 to
707d9df
Compare
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
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.