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 357d8c1746 [enhance](Nereids): remove rule flag in LogicalJoin (#17452) 357d8c1746 is described below commit 357d8c1746374f1ef2199aa2015073a6ea7a81b9 Author: jakevin <jakevin...@gmail.com> AuthorDate: Tue Mar 7 13:18:50 2023 +0800 [enhance](Nereids): remove rule flag in LogicalJoin (#17452) --- .../rules/rewrite/logical/InferJoinNotNull.java | 8 ++-- .../nereids/trees/plans/logical/LogicalJoin.java | 43 +++++++--------------- .../rewrite/logical/InferJoinNotNullTest.java | 1 - 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNull.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNull.java index 4887898637..f565b5727e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNull.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNull.java @@ -42,8 +42,8 @@ public class InferJoinNotNull extends OneRewriteRuleFactory { @Override public Rule build() { // TODO: maybe consider ANTI? - return logicalJoin().when(join -> join.getJoinType().isInnerJoin() || join.getJoinType().isSemiJoin()) - .whenNot(LogicalJoin::isGenerateIsNotNull) + return logicalJoin(any(), any()) + .when(join -> join.getJoinType().isInnerJoin() || join.getJoinType().isSemiJoin()) .thenApply(ctx -> { LogicalJoin<Plan, Plan> join = ctx.root; Set<Expression> conjuncts = new HashSet<>(); @@ -69,10 +69,10 @@ public class InferJoinNotNull extends OneRewriteRuleFactory { right = PlanUtils.filterOrSelf(rightNotNull, join.right()); } - if (left == join.left() && right == join.right()) { + if (left.equals(join.left()) && right.equals(join.right())) { return null; } - return join.withIsGenerateIsNotNullAndChildren(true, left, right); + return join.withChildren(left, right); }).toRule(RuleType.INFER_JOIN_NOT_NULL); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java index 3214d71fb0..9a4734213c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java @@ -58,23 +58,21 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends // Use for top-to-down join reorder private final JoinReorderContext joinReorderContext = new JoinReorderContext(); - private final boolean isGenerateIsNotNull; - public LogicalJoin(JoinType joinType, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) { this(joinType, ExpressionUtils.EMPTY_CONDITION, ExpressionUtils.EMPTY_CONDITION, JoinHint.NONE, - Optional.empty(), Optional.empty(), leftChild, rightChild, false); + Optional.empty(), Optional.empty(), leftChild, rightChild); } public LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) { this(joinType, hashJoinConjuncts, ExpressionUtils.EMPTY_CONDITION, JoinHint.NONE, Optional.empty(), - Optional.empty(), leftChild, rightChild, false); + Optional.empty(), leftChild, rightChild); } public LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts, List<Expression> otherJoinConjuncts, JoinHint hint, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) { this(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, Optional.empty(), Optional.empty(), leftChild, - rightChild, false); + rightChild); } /** @@ -82,13 +80,12 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends */ private LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts, List<Expression> otherJoinConjuncts, JoinHint hint, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild, - JoinReorderContext joinReorderContext, boolean isGenerateIsNotNull) { + JoinReorderContext joinReorderContext) { super(PlanType.LOGICAL_JOIN, Optional.empty(), Optional.empty(), leftChild, rightChild); this.joinType = Objects.requireNonNull(joinType, "joinType can not be null"); this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts); this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts); this.hint = Objects.requireNonNull(hint, "hint can not be null"); - this.isGenerateIsNotNull = isGenerateIsNotNull; this.joinReorderContext.copyFrom(joinReorderContext); } @@ -100,14 +97,12 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends Optional<GroupExpression> groupExpression, Optional<LogicalProperties> logicalProperties, LEFT_CHILD_TYPE leftChild, - RIGHT_CHILD_TYPE rightChild, - boolean isGenerateIsNotNull) { + RIGHT_CHILD_TYPE rightChild) { super(PlanType.LOGICAL_JOIN, groupExpression, logicalProperties, leftChild, rightChild); this.joinType = Objects.requireNonNull(joinType, "joinType can not be null"); this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts); this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts); this.hint = Objects.requireNonNull(hint, "hint can not be null"); - this.isGenerateIsNotNull = isGenerateIsNotNull; } public List<Expression> getOtherJoinConjuncts() { @@ -136,10 +131,6 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends return hint; } - public boolean isGenerateIsNotNull() { - return isGenerateIsNotNull; - } - public JoinReorderContext getJoinReorderContext() { return joinReorderContext; } @@ -212,13 +203,13 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends public LogicalJoin<Plan, Plan> withChildren(List<Plan> children) { Preconditions.checkArgument(children.size() == 2); return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, children.get(0), - children.get(1), joinReorderContext, isGenerateIsNotNull); + children.get(1), joinReorderContext); } @Override public LogicalJoin<Plan, Plan> withGroupExpression(Optional<GroupExpression> groupExpression) { LogicalJoin<Plan, Plan> newJoin = new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, - groupExpression, Optional.of(getLogicalProperties()), left(), right(), isGenerateIsNotNull); + groupExpression, Optional.of(getLogicalProperties()), left(), right()); newJoin.getJoinReorderContext().copyFrom(this.getJoinReorderContext()); return newJoin; } @@ -226,48 +217,42 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends @Override public LogicalJoin<Plan, Plan> withLogicalProperties(Optional<LogicalProperties> logicalProperties) { LogicalJoin<Plan, Plan> newJoin = new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, - Optional.empty(), logicalProperties, left(), right(), isGenerateIsNotNull); + Optional.empty(), logicalProperties, left(), right()); newJoin.getJoinReorderContext().copyFrom(this.getJoinReorderContext()); return newJoin; } public LogicalJoin<Plan, Plan> withHashJoinConjuncts(List<Expression> hashJoinConjuncts) { return new LogicalJoin<>(joinType, hashJoinConjuncts, this.otherJoinConjuncts, hint, left(), right(), - joinReorderContext, isGenerateIsNotNull); + joinReorderContext); } public LogicalJoin<Plan, Plan> withJoinConjuncts( List<Expression> hashJoinConjuncts, List<Expression> otherJoinConjuncts) { return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, - hint, left(), right(), joinReorderContext, isGenerateIsNotNull); + hint, left(), right(), joinReorderContext); } public LogicalJoin<Plan, Plan> withHashJoinConjunctsAndChildren( List<Expression> hashJoinConjuncts, List<Plan> children) { Preconditions.checkArgument(children.size() == 2); return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, children.get(0), - children.get(1), joinReorderContext, isGenerateIsNotNull); + children.get(1), joinReorderContext); } public LogicalJoin<Plan, Plan> withConjunctsChildren(List<Expression> hashJoinConjuncts, List<Expression> otherJoinConjuncts, Plan left, Plan right) { return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, left, - right, joinReorderContext, isGenerateIsNotNull); + right, joinReorderContext); } public LogicalJoin<Plan, Plan> withJoinType(JoinType joinType) { return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, left(), right(), - joinReorderContext, isGenerateIsNotNull); + joinReorderContext); } public LogicalJoin<Plan, Plan> withOtherJoinConjuncts(List<Expression> otherJoinConjuncts) { return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, left(), right(), - joinReorderContext, isGenerateIsNotNull); - } - - public LogicalJoin<Plan, Plan> withIsGenerateIsNotNullAndChildren(boolean isGenerateIsNotNull, - Plan left, Plan right) { - return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, left, - right, joinReorderContext, isGenerateIsNotNull); + joinReorderContext); } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNullTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNullTest.java index 6ba1ed4bed..231de8b20f 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNullTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/InferJoinNotNullTest.java @@ -32,7 +32,6 @@ import org.junit.jupiter.api.Test; class InferJoinNotNullTest implements MemoPatternMatchSupported { private final LogicalOlapScan scan1 = PlanConstructor.newLogicalOlapScan(0, "t1", 0); private final LogicalOlapScan scan2 = PlanConstructor.newLogicalOlapScan(1, "t2", 0); - private final LogicalOlapScan scan3 = PlanConstructor.newLogicalOlapScan(2, "t3", 0); @Test void testInferIsNotNull() { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org