[fix](Nereids): when predicate contains right output, don't convert outer to anti join (#30276)

This commit is contained in:
谢健
2024-01-25 14:01:27 +08:00
committed by yiguolei
parent bb021668c9
commit 0a5c375068
2 changed files with 84 additions and 4 deletions

View File

@ -81,7 +81,8 @@ public class ConvertOuterJoinToAntiJoin extends OneRewriteRuleFactory {
&& rightAlwaysNullSlots.containsAll(p.getInputSlots())))
.collect(ImmutableSet.toImmutableSet());
boolean containRightSlot = predicates.stream()
.anyMatch(s -> join.right().getOutputSet().containsAll(s.getInputSlots()));
.flatMap(p -> p.getInputSlots().stream())
.anyMatch(join.right().getOutputSet()::contains);
if (!containRightSlot) {
res = join.withJoinType(JoinType.LEFT_ANTI_JOIN);
res = predicates.isEmpty() ? res : filter.withConjuncts(predicates).withChildren(res);
@ -94,7 +95,8 @@ public class ConvertOuterJoinToAntiJoin extends OneRewriteRuleFactory {
&& leftAlwaysNullSlots.containsAll(p.getInputSlots())))
.collect(ImmutableSet.toImmutableSet());
boolean containLeftSlot = predicates.stream()
.anyMatch(s -> join.left().getOutputSet().containsAll(s.getInputSlots()));
.flatMap(p -> p.getInputSlots().stream())
.anyMatch(join.left().getOutputSet()::contains);
if (!containLeftSlot) {
res = join.withJoinType(JoinType.RIGHT_ANTI_JOIN);
res = predicates.isEmpty() ? res : filter.withConjuncts(predicates).withChildren(res);