github-actions[bot] commented on code in PR #65205:
URL: https://github.com/apache/doris/pull/65205#discussion_r3541707777


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/hint/LeadingHint.java:
##########
@@ -416,13 +416,20 @@ public Pair<JoinConstraint, Boolean> 
getJoinConstraint(Long joinTableBitmap, Lon
                 continue;
             }
 
-            if (joinConstraint.getJoinType().isSemiJoin()) {
-                if (LongBitmap.isSubset(joinConstraint.getRightHand(), 
leftTableBitmap)
-                        && !LongBitmap.isSubset(joinConstraint.getRightHand(), 
leftTableBitmap)) {
+            if (joinConstraint.getJoinType().isSemiOrAntiJoin()) {
+                if (!LongBitmap.isSubset(joinConstraint.getLeftHand(), 
joinTableBitmap)

Review Comment:
   This check now requires both full original hands to be present before a 
semi/anti constraint can match, which rejects legal orders where the retained 
side contains tables that can be joined later. A reduced plan is:
   
   ```text
   (A INNER JOIN C) LEFT SEMI JOIN B ON A.k = B.k
   ```
   
   `CollectJoinConstraint` records this as `leftHand = A|C`, `rightHand = B`, 
but the minimal hands are only `minLeftHand = A` and `minRightHand = B`. The 
existing min-hand branch below would allow the valid leading step 
`getJoinConstraint(A|B, A, B)` so the generated plan can do `(A LEFT SEMI B) 
INNER JOIN C`; the A-C filter is still applied at the later join. With this new 
guard, `leftHand = A|C` is not a subset of the current `joinTableBitmap = A|B`, 
so the constraint is skipped and the leading hint is unnecessarily treated as 
unavailable. Please keep the full/exact requirement on the constrained 
filtering side, but let the retained side continue to use the existing 
`minLeftHand`/`minRightHand` logic, with unit coverage where the retained side 
is composite.



-- 
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]

Reply via email to