You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ja...@apache.org on 2023/06/30 12:29:56 UTC
[doris] branch master updated: [fix](Nereids): reject infer distinct when children exist NLJ (#21391)
This is an automated email from the ASF dual-hosted git repository.
jakevin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 18b7d84436 [fix](Nereids): reject infer distinct when children exist NLJ (#21391)
18b7d84436 is described below
commit 18b7d84436c00576a12bce491ec6c847b77fe555
Author: jakevin <ja...@gmail.com>
AuthorDate: Fri Jun 30 20:29:48 2023 +0800
[fix](Nereids): reject infer distinct when children exist NLJ (#21391)
---
.../rules/rewrite/InferSetOperatorDistinct.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferSetOperatorDistinct.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferSetOperatorDistinct.java
index c77edb2e17..8b9f46408f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferSetOperatorDistinct.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferSetOperatorDistinct.java
@@ -22,6 +22,8 @@ import org.apache.doris.nereids.rules.RuleType;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.algebra.SetOperation.Qualifier;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import com.google.common.collect.ImmutableList;
@@ -41,7 +43,12 @@ public class InferSetOperatorDistinct extends OneRewriteRuleFactory {
public Rule build() {
return logicalSetOperation()
.when(operation -> operation.getQualifier() == Qualifier.DISTINCT)
+ .when(operation -> operation.children().stream().allMatch(this::rejectNLJ))
.then(setOperation -> {
+ if (setOperation.children().stream().anyMatch(child -> child instanceof LogicalAggregate)) {
+ return null;
+ }
+
List<Plan> newChildren = setOperation.children().stream()
.map(child -> new LogicalAggregate<>(ImmutableList.copyOf(child.getOutput()), child))
.collect(ImmutableList.toImmutableList());
@@ -51,4 +58,16 @@ public class InferSetOperatorDistinct extends OneRewriteRuleFactory {
return setOperation.withChildren(newChildren);
}).toRule(RuleType.INFER_SET_OPERATOR_DISTINCT);
}
+
+ // if children exist NLJ, we can't infer distinct
+ private boolean rejectNLJ(Plan plan) {
+ if (plan instanceof LogicalProject) {
+ plan = plan.child(0);
+ }
+ if (plan instanceof LogicalJoin) {
+ LogicalJoin<?, ?> join = (LogicalJoin<?, ?>) plan;
+ return join.getOtherJoinConjuncts().isEmpty();
+ }
+ return true;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org