branch-4.0: [fix](mark join) Fix invalid semi-join transpose when the bottom join is a mark join #66574 - #66621
Open
github-actions[bot] wants to merge 1 commit into
Open
branch-4.0: [fix](mark join) Fix invalid semi-join transpose when the bottom join is a mark join #66574#66621github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
… is a mark join (#66574) ### What problem does this PR solve? Problem Summary: A query with a subquery inside the ON condition of an anti join failed at physical planning with "A expression contains slot not from children", e.g.: ```sql SELECT t1.* FROM t1 LEFT ANTI JOIN t2 ON t1.k2 = t2.k3 AND t1.k1 NOT IN (SELECT t3.k1 FROM t3 WHERE t1.k2 = t3.k2); ``` The subquery is unnested into a mark join `(t1 LEFT ANTI JOIN t3)` that produces a mark slot, and the outer anti join references the mark slot in its conjuncts. Root cause: the exploration rule `SemiJoinSemiJoinTransposeProject` transposes two nested left semi/anti joins `(A ⟕̸ B) ⟕̸ C` into `(A ⟕̸ C) ⟕̸ B`. When the bottom join `(A ⟕̸ B)` is a mark join, the transposed plan builds `newBottomSemi = (A ⟕̸ C)` from the top join, inheriting the top join's conjuncts that reference the bottom mark slot, while the mark slot is now produced above by the new top mark join. The mark slot is therefore referenced by a join whose children don't output it, and physical planning fails with "slot not from children". The fix rejects the transpose when the bottom semi join is a mark join and the top semi join references the bottom mark slot in its conjuncts, so the mark join is always kept below the join that consumes the mark slot. After the fix the query above executes correctly and returns the expected result.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
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.
Cherry-picked from #66574