starocean999 opened a new pull request, #65467:
URL: https://github.com/apache/doris/pull/65467
Related PR: #65205
Problem Summary:
PR #65205 refactored the semi/anti join constraint matching in
`LeadingHint#getJoinConstraint()` to support both semi and anti joins and
handle the constrained side correctly. However, it introduced two bugs that
together cause semi/anti joins to be silently downgraded to INNER/CROSS JOIN:
1. When the constrained side (probe side for left semi/anti, or left side for
right semi/anti) partially overlaps a join child but that child contains
extra tables, the new code does `continue` — skipping the constraint
instead of marking the leading hint as UNUSED. Since
`matchedJoinConstraint`
remains null, `computeJoinType()` falls through to INNER_JOIN or
CROSS_JOIN,
silently dropping the semi/anti semantics.
Example SQL triggering this:
```sql
SELECT /*+ leading(a2 a5 { a3 a1 }) */ COUNT(*)
FROM a1 JOIN a2 ON a2.c1 = a2.c1
LEFT SEMI JOIN a3 ON a2.c2 = a2.c1
JOIN a5 ON a2.c2 = a2.c1;
```
2. The conditionJoinType map uses HashMap<Expression, JoinType> with
put(), so when the same Expression appears in both a semi/anti join
condition and an inner join condition, the later inner join overwrites
the semi/anti join type. This disables the isConditionJoinTypeMatched()
safety net that should have caught the fallback from bug 1.
Root cause:
For bug 1: continue on constrained-side violation should be
return Pair.of(null, false) to indicate the constraint is broken, not
silently skipped.
For bug 2: a single-value-per-key map cannot represent that one expression
belongs to multiple join types. Changed to Map<Expression, Set<JoinType>>
using computeIfAbsent(...).add().
### 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]