Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -416,20 +416,13 @@ public Pair<JoinConstraint, Boolean> getJoinConstraint(Long joinTableBitmap, Lon
continue;
}

if (joinConstraint.getJoinType().isSemiOrAntiJoin()) {
if (!LongBitmap.isSubset(joinConstraint.getMinLeftHand(), joinTableBitmap)
|| !LongBitmap.isSubset(joinConstraint.getMinRightHand(), joinTableBitmap)) {
if (joinConstraint.getJoinType().isSemiJoin()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This restores the old constrained-side bug for leading hints. For semi/anti joins the full non-retained side has to remain wholly on one child before the constraint can match, but this block now only runs for isSemiJoin(), the first predicate is impossible (isSubset(rightHand, leftTableBitmap) && !isSubset(rightHand, leftTableBitmap)), and right semi joins still check rightHand even though their constrained side is leftHand.

For example, with a left-semi constraint minLeft=A, minRight=B, leftHand=A, rightHand=B|C, a leading split left=A|C, right=B skips this guard and then matches lines 430-436 because the min hands are present, producing (A join C) LEFT_SEMI B even though C belonged to the constrained right side. Left anti follows the same path because anti joins no longer enter the guard at all. The deleted LeadingHintTest had direct cases for these semi/anti constrained-side splits, so this PR reintroduces the bad match and removes the coverage that would catch it.

if (LongBitmap.isSubset(joinConstraint.getRightHand(), leftTableBitmap)
&& !LongBitmap.isSubset(joinConstraint.getRightHand(), leftTableBitmap)) {
continue;
}

Long constrainedSide = joinConstraint.getJoinType().isRightSemiOrAntiJoin()
? joinConstraint.getLeftHand() : joinConstraint.getRightHand();
if (LongBitmap.isOverlap(constrainedSide, leftTableBitmap)
&& !constrainedSide.equals(leftTableBitmap)) {
continue;
}
if (LongBitmap.isOverlap(constrainedSide, rightTableBitmap)
&& !constrainedSide.equals(rightTableBitmap)) {
if (LongBitmap.isSubset(joinConstraint.getRightHand(), rightTableBitmap)
&& !joinConstraint.getRightHand().equals(rightTableBitmap)) {
continue;
}
}
Expand Down

This file was deleted.

Loading