starocean999 opened a new pull request, #67645:
URL: https://github.com/apache/doris/pull/67645
…
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
When the `LEADING` hint is used on a FULL OUTER JOIN whose ON condition
references only one side, rows from the preserved side that fail the
conjunct are dropped instead of being output with the other side
null-extended. For example:
SELECT /*+ LEADING(a,b) */ a.p, b.q
FROM r1_a AS a FULL OUTER JOIN r1_b AS b ON a.p > 0;
with `a = {0,1}` and `b = {7}` should return `(0,NULL),(1,7)` but only
returns `(1,7)`; the symmetric case `ON b.q > 0` similarly loses
`(NULL,0)`. The wrong plan shows the predicate leaked into the input
scan (`A-side scan: PREDICATES: (p[#1] > 0)`), so the offending rows
were filtered out before the join could null-extend them.
Root cause: `CollectJoinConstraint` records every ON conjunct together
with the table bitmap of the tables it references. When the `LEADING`
hint rebuilds the join tree, `LeadingHint.makeFilterPlanIfExist` pushes
a conjunct into a scan whenever its bitmap is a subset of that scan's
table set. A LEFT JOIN conjunct that references only the preserved
(left) side is already protected from such pushdown by OR-ing its
bitmap with the nullable (right) side's bitmap (see #32286). However
`JoinType.isLeftJoin()` does not include `FULL_OUTER_JOIN`, and a FULL
OUTER JOIN preserves rows from *both* sides, so a one-sided conjunct
such as `a.p > 0` was pushed into scan `a` and deleted rows there.
Fix: in `CollectJoinConstraint`, mirror the LEFT JOIN handling for
FULL OUTER JOIN — OR the conjunct's table bitmap with *both* children's
bitmaps, so a one-sided conjunct always stays attached as the full
outer join's own condition and can never be pushed into either input.
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]