From 5d1d70dd8de7549ae13162ef45a9f8f065531820 Mon Sep 17 00:00:00 2001 From: jackwener Date: Wed, 13 Mar 2024 13:05:03 +0800 Subject: [PATCH] [fix](Nereids): slot set in condition can be empty --- .../rules/exploration/join/InnerJoinLAsscom.java | 6 +++--- .../rules/rewrite/TransposeSemiJoinLogicalJoin.java | 2 +- .../rewrite/TransposeSemiJoinLogicalJoinProject.java | 10 +++++----- 3 files changed, 9 insertions(+), 9 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 06d7d68ffc0119..37ff912af22e88 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 @@ -69,10 +69,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 d0068f9faeaa91..7ee1dcf94f98b8 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 25e1879acc051a..95065e1b33dab1 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 @@ -29,7 +29,6 @@ import org.apache.doris.nereids.util.Utils; import org.apache.doris.qe.ConnectContext; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import java.util.Set; @@ -63,7 +62,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; } ImmutableList topProjects = topSemiJoin.getOutput().stream() @@ -113,7 +112,7 @@ public Rule build() { } enum ContainsType { - LEFT, RIGHT, ALL + LEFT, RIGHT, ALL, NONE } /** @@ -122,13 +121,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; } } }