github-actions[bot] commented on code in PR #65467:
URL: https://github.com/apache/doris/pull/65467#discussion_r3567608684
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/hint/LeadingHint.java:
##########
@@ -295,14 +311,23 @@ public void putConditionJoinType(Expression filter,
JoinType joinType) {
*/
public boolean isConditionJoinTypeMatched(List<Expression> conditions,
JoinType joinType) {
for (Expression condition : conditions) {
- JoinType originalJoinType = conditionJoinType.get(condition);
- if (originalJoinType.equals(joinType)
- || originalJoinType.isOneSideOuterJoin() &&
joinType.isOneSideOuterJoin()
- || originalJoinType.isSemiJoin() && joinType.isSemiJoin()
- || originalJoinType.isAntiJoin() && joinType.isAntiJoin())
{
+ Set<JoinType> originalJoinTypes = conditionJoinType.get(condition);
+ if (originalJoinTypes == null) {
continue;
}
- return false;
+ boolean matched = false;
+ for (JoinType originalJoinType : originalJoinTypes) {
+ if (originalJoinType.equals(joinType)
+ || originalJoinType.isOneSideOuterJoin() &&
joinType.isOneSideOuterJoin()
+ || originalJoinType.isSemiJoin() &&
joinType.isSemiJoin()
+ || originalJoinType.isAntiJoin() &&
joinType.isAntiJoin()) {
Review Comment:
The set lookup here loses which collected filter occurrence came from which
original join. A same expression can be collected twice with different bitmaps.
For example, in a reduced tree like:
```text
InnerJoin ON a.v > 0
LeftAntiJoin ON a.k = b.k AND a.v > 0
a
b
c
```
`CollectJoinConstraint` records the anti occurrence with bitmap `{a,b}`
because left anti is treated as a left join and ORs in the right hand, and
records the upper inner occurrence with bitmap `{a}`. Both predicates have the
same `Expression` key, so this map now contains both `LEFT_ANTI_JOIN` and
`INNER_JOIN`. When `leading(a b c)` builds the first `{a,b}` join,
`getJoinConditions` removes both filter occurrences because both bitmaps are
subsets of `{a,b}`. `computeJoinType` returns `LEFT_ANTI_JOIN`, and this loop
accepts both removed conditions because the set contains an anti type. The
upper inner predicate is then gone from the later join with `c`, so rows where
`a.v > 0` is false can survive the anti join and then join/cross with `c`,
whereas the original upper inner join would filter them. Please keep the
original join type on each collected filter occurrence, or only consume
occurrences whose own original type is compatible with the generated join.
--
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]