From 334201ebe1964464d02f66ead0bef51a0777b571 Mon Sep 17 00:00:00 2001 From: jakevin Date: Wed, 13 Mar 2024 15:33:13 +0800 Subject: [PATCH] [fix](Nereids): slot set in condition can be empty (#32169) (cherry picked from commit ca092139a007dca99006d8247d9926947b1490d3) --- .../rules/exploration/join/InnerJoinLAsscom.java | 6 +++--- .../rules/rewrite/TransposeSemiJoinLogicalJoin.java | 2 +- .../rewrite/TransposeSemiJoinLogicalJoinProject.java | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscom.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscom.java index d7d81e3461c883..9b86458634a433 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscom.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscom.java @@ -70,10 +70,10 @@ public Rule build() { List newBottomHashConjuncts = splitHashConjuncts.get(false); // split OtherJoinConjuncts. - Map> splitOtherConjunts = splitConjuncts(topJoin.getOtherJoinConjuncts(), + Map> splitOtherConjuncts = splitConjuncts(topJoin.getOtherJoinConjuncts(), bottomJoin, bottomJoin.getOtherJoinConjuncts()); - List newTopOtherConjuncts = splitOtherConjunts.get(true); - List newBottomOtherConjuncts = splitOtherConjunts.get(false); + List newTopOtherConjuncts = splitOtherConjuncts.get(true); + List newBottomOtherConjuncts = splitOtherConjuncts.get(false); if (newBottomHashConjuncts.isEmpty() && newBottomOtherConjuncts.isEmpty()) { return null; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoin.java index 7d4d639f745515..fe31b2f7947b4b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoin.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoin.java @@ -54,7 +54,7 @@ public Rule build() { Set conjunctsIds = topSemiJoin.getConditionExprId(); ContainsType containsType = TransposeSemiJoinLogicalJoinProject.containsChildren(conjunctsIds, a.getOutputExprIdSet(), b.getOutputExprIdSet()); - if (containsType == ContainsType.ALL) { + if (containsType == ContainsType.ALL || containsType == ContainsType.NONE) { return null; } if (containsType == ContainsType.LEFT) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoinProject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoinProject.java index 8408c23d50c616..b82dc880f5fe05 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoinProject.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinLogicalJoinProject.java @@ -28,8 +28,6 @@ import org.apache.doris.nereids.util.Utils; import org.apache.doris.qe.ConnectContext; -import com.google.common.base.Preconditions; - import java.util.Set; /** @@ -61,7 +59,7 @@ public Rule build() { Set conjunctsIds = topSemiJoin.getConditionExprId(); ContainsType containsType = containsChildren(conjunctsIds, a.getOutputExprIdSet(), b.getOutputExprIdSet()); - if (containsType == ContainsType.ALL) { + if (containsType == ContainsType.ALL || containsType == ContainsType.NONE) { return null; } @@ -110,7 +108,7 @@ public Rule build() { } enum ContainsType { - LEFT, RIGHT, ALL + LEFT, RIGHT, ALL, NONE } /** @@ -119,13 +117,14 @@ enum ContainsType { public static ContainsType containsChildren(Set conjunctsExprIdSet, Set left, Set right) { boolean containsLeft = Utils.isIntersecting(conjunctsExprIdSet, left); boolean containsRight = Utils.isIntersecting(conjunctsExprIdSet, right); - Preconditions.checkState(containsLeft || containsRight, "join output must contain child"); if (containsLeft && containsRight) { return ContainsType.ALL; } else if (containsLeft) { return ContainsType.LEFT; - } else { + } else if (containsRight) { return ContainsType.RIGHT; + } else { + return ContainsType.NONE; } } }