feat(pwmj): support LeftSemi/LeftAnti existence joins via classic scan#23870
Open
SubhamSinghal wants to merge 1 commit into
Open
feat(pwmj): support LeftSemi/LeftAnti existence joins via classic scan#23870SubhamSinghal wants to merge 1 commit into
SubhamSinghal wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #23870 +/- ##
========================================
Coverage 80.71% 80.72%
========================================
Files 1090 1090
Lines 370339 370906 +567
Branches 370339 370906 +567
========================================
+ Hits 298925 299411 +486
- Misses 53605 53607 +2
- Partials 17809 17888 +79 ☔ 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 close?
Part of #17427 (Make
PiecewiseMergeJoinwork in DataFusion). AddsLeftSemi/LeftAntisupport, one of the epic's checklist items. Supersedes the stale #18392, taking the alternative approach that @2010YOUY01 suggested there (reuse the classic join path for generality) rather than a dedicated existence stream.Rationale for this change
An inequality-correlated
EXISTS/NOT EXISTS(e.g.WHERE EXISTS (SELECT 1 FROM r WHERE l.x < r.y)) has no equi-key, so it decorrelates to aLeftSemi/LeftAntijoin with a single range predicate. TodayPiecewiseMergeJoinExecrejects existence joins (not_impl_err!) and these queries fall back toNestedLoopJoinExec, which is O(n*m).Microbenchmark (20K × 20K rows, single inequality,
enable_piecewise_merge_joinon vs off), added in this PR as
piecewise_merge_join_semi_anti:What changes are included in this PR?
Existence joins (
LeftSemi/LeftAnti) forPiecewiseMergeJoin:LeftSemi/LeftAntiwith a single range predicate toPiecewiseMergeJoinExecin the physical planner (still gated behindenable_piecewise_merge_join, defaultfalse).LeftSemi= marked rows,LeftAnti= unmarked; NULL join keys are never marked, so they are correctly excluded from Semi and included in Anti). Only left-side columns are produced.RightSemi/RightAnti/Markremain unsupported (they require swapping the inputs); they are still rejected intry_newand excluded in the planner. Left as a follow-up.Are these changes tested?
Yes.
classic_join.rscoveringLeftSemi/LeftAntiacross<,<=,>,>=; NULL join keys; all-null streamed side; empty inputs;Date32keys; multi-batch and multi-partition streamed inputs; and the low-water-mark skip branch.pwmj.sltforEXISTS/NOT EXISTS(including NULLs) withEXPLAINassertions confirming the plan usesPiecewiseMergeJoin.Are there any user-facing changes?
No behaviour change by default:
enable_piecewise_merge_joinremainsfalse. When enabled, single-range-predicateLeftSemi/LeftAntijoins are planned asPiecewiseMergeJoininstead ofNestedLoopJoin. No API changes.