github-actions[bot] commented on code in PR #65205:
URL: https://github.com/apache/doris/pull/65205#discussion_r3526284148
##########
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)
+ || !LongBitmap.isSubset(joinConstraint.getRightHand(),
joinTableBitmap)) {
continue;
}
- if (LongBitmap.isSubset(joinConstraint.getRightHand(),
rightTableBitmap)
- &&
!joinConstraint.getRightHand().equals(rightTableBitmap)) {
+
+ Long constrainedSide =
joinConstraint.getJoinType().isRightSemiOrAntiJoin()
+ ? joinConstraint.getLeftHand() :
joinConstraint.getRightHand();
+ if (LongBitmap.isSubset(constrainedSide, leftTableBitmap)
Review Comment:
This still accepts cases where the constrained semi/anti side is split
across both candidate children. For example, a collected constraint from `(A
CROSS JOIN C) RIGHT SEMI JOIN B ON A.k = B.k` has full `leftHand = A|C` and
`rightHand = B`, but `minLeftHand` can be only `A`. With a leading step
`getJoinConstraint(A|B|C, A, B|C)`, `constrainedSide` is `A|C`; it is not a
subset of either child, so both exact checks are skipped and the later
`minLeftHand/minRightHand` match returns `RIGHT_SEMI_JOIN`. That rewrites the
join as `A RIGHT SEMI (B CROSS C)`, whose output is the whole right child
`B|C`, while the original right semi join outputs only `B` and uses all of
`A|C` only for existence testing. Please reject any child that partially
overlaps the constrained side without equaling it, and add unit coverage where
`leftHand`/`rightHand` is composite but the corresponding `min*Hand` is
narrower.
--
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]