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 85c2060862 [Minor](Nereids): minor fix (#16095) 85c2060862 is described below commit 85c2060862b70d22252eaf4121e61654ce0080f0 Author: jakevin <jakevin...@gmail.com> AuthorDate: Fri Jan 20 00:53:11 2023 +0800 [Minor](Nereids): minor fix (#16095) --- .../jobs/joinorder/hypergraph/HyperGraph.java | 2 +- .../rules/exploration/join/InnerJoinLAsscom.java | 6 +-- .../rules/exploration/join/JoinReorderContext.java | 13 +---- .../PushdownExpressionsInHashCondition.java | 2 +- .../nereids/trees/plans/logical/LogicalJoin.java | 61 ++++++++-------------- 5 files changed, 29 insertions(+), 55 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java index 365a12a727..4c5860b052 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java @@ -129,7 +129,7 @@ public class HyperGraph { Preconditions.checkArgument(group.isJoinGroup()); LogicalJoin<? extends Plan, ? extends Plan> join = (LogicalJoin) group.getLogicalExpression().getPlan(); for (Expression expression : join.getExpressions()) { - LogicalJoin singleJoin = new LogicalJoin(join.getJoinType(), ImmutableList.of(expression), join.left(), + LogicalJoin singleJoin = new LogicalJoin<>(join.getJoinType(), ImmutableList.of(expression), join.left(), join.right()); Edge edge = new Edge(singleJoin, edges.size()); Preconditions.checkArgument(expression.children().size() == 2); 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 64206556a5..459b5f2bdb 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 @@ -61,10 +61,10 @@ public class InnerJoinLAsscom extends OneExplorationRuleFactory { GroupPlan c = topJoin.right(); // split HashJoinConjuncts. - Map<Boolean, List<Expression>> splitHashConjunts = splitConjuncts(topJoin.getHashJoinConjuncts(), + Map<Boolean, List<Expression>> splitHashConjuncts = splitConjuncts(topJoin.getHashJoinConjuncts(), bottomJoin, bottomJoin.getHashJoinConjuncts()); - List<Expression> newTopHashConjuncts = splitHashConjunts.get(true); - List<Expression> newBottomHashConjuncts = splitHashConjunts.get(false); + List<Expression> newTopHashConjuncts = splitHashConjuncts.get(true); + List<Expression> newBottomHashConjuncts = splitHashConjuncts.get(false); Preconditions.checkState(!newTopHashConjuncts.isEmpty(), "LAsscom newTopHashJoinConjuncts join can't empty"); if (newBottomHashConjuncts.size() == 0) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinReorderContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinReorderContext.java index 0109c172f4..373fbbe8d9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinReorderContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinReorderContext.java @@ -25,6 +25,8 @@ package org.apache.doris.nereids.rules.exploration.join; * - Improving Join Reorderability with Compensation Operators */ public class JoinReorderContext { + public static final JoinReorderContext EMPTY = new JoinReorderContext(); + // left deep tree private boolean hasCommute = false; private boolean hasLAsscom = false; @@ -37,9 +39,6 @@ public class JoinReorderContext { private boolean hasRightAssociate = false; private boolean hasLeftAssociate = false; - // mark for whether it has applied HyperGraph. - private boolean hasHyperReorder = false; - public JoinReorderContext() { } @@ -114,12 +113,4 @@ public class JoinReorderContext { public void setHasCommuteZigZag(boolean hasCommuteZigZag) { this.hasCommuteZigZag = hasCommuteZigZag; } - - public boolean hasHyperReorder() { - return hasHyperReorder; - } - - public void setHasHyperReorder(boolean hasHyperReorder) { - this.hasHyperReorder = hasHyperReorder; - } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/PushdownExpressionsInHashCondition.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/PushdownExpressionsInHashCondition.java index f6e39ea32a..e02d2dea6d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/PushdownExpressionsInHashCondition.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/PushdownExpressionsInHashCondition.java @@ -82,7 +82,7 @@ public class PushdownExpressionsInHashCondition extends OneRewriteRuleFactory { exprMap.put(expr, new Alias(expr, "expr_" + expr.toSql()))); }); Iterator<List<Expression>> iter = exprsOfHashConjuncts.iterator(); - return join.withhashJoinConjunctsAndChildren( + return join.withHashJoinConjunctsAndChildren( join.getHashJoinConjuncts().stream() .map(equalTo -> equalTo.withChildren(equalTo.children() .stream().map(expr -> exprMap.get(expr).toSlot()) 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 61f0bfeca9..2897fa6402 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 @@ -61,13 +61,13 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends */ 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); + Optional.empty(), Optional.empty(), leftChild, rightChild, JoinReorderContext.EMPTY); } 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); + Optional.empty(), leftChild, rightChild, JoinReorderContext.EMPTY); } public LogicalJoin( @@ -77,7 +77,8 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends JoinHint hint, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) { this(joinType, hashJoinConjuncts, - otherJoinConjuncts, hint, Optional.empty(), Optional.empty(), leftChild, rightChild); + otherJoinConjuncts, hint, Optional.empty(), Optional.empty(), leftChild, rightChild, + JoinReorderContext.EMPTY); } public LogicalJoin( @@ -88,8 +89,7 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends RIGHT_CHILD_TYPE rightChild, JoinReorderContext joinReorderContext) { this(joinType, hashJoinConjuncts, ExpressionUtils.EMPTY_CONDITION, hint, - Optional.empty(), Optional.empty(), leftChild, rightChild); - this.joinReorderContext.copyFrom(joinReorderContext); + Optional.empty(), Optional.empty(), leftChild, rightChild, joinReorderContext); } public LogicalJoin( @@ -101,29 +101,11 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends RIGHT_CHILD_TYPE rightChild, JoinReorderContext joinReorderContext) { this(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, - Optional.empty(), Optional.empty(), leftChild, rightChild); - this.joinReorderContext.copyFrom(joinReorderContext); - } - - public LogicalJoin( - JoinType joinType, - List<Expression> hashJoinConjuncts, - List<Expression> otherJoinConjuncts, - JoinHint hint, - Optional<GroupExpression> groupExpression, - Optional<LogicalProperties> logicalProperties, - LEFT_CHILD_TYPE leftChild, - RIGHT_CHILD_TYPE rightChild, - JoinReorderContext joinReorderContext) { - this(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, groupExpression, logicalProperties, leftChild, - rightChild); - this.joinReorderContext.copyFrom(joinReorderContext); + Optional.empty(), Optional.empty(), leftChild, rightChild, joinReorderContext); } /** * Constructor for LogicalJoinPlan. - * - * @param joinType logical type for join */ public LogicalJoin( JoinType joinType, @@ -133,12 +115,14 @@ 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) { + RIGHT_CHILD_TYPE rightChild, + JoinReorderContext joinReorderContext) { 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.joinReorderContext.copyFrom(joinReorderContext); } public List<Expression> getOtherJoinConjuncts() { @@ -162,6 +146,10 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends return hint; } + public JoinReorderContext getJoinReorderContext() { + return joinReorderContext; + } + @Override public List<Slot> computeOutput() { @@ -253,8 +241,14 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends .build(); } - public JoinReorderContext getJoinReorderContext() { - return joinReorderContext; + @Override + public LEFT_CHILD_TYPE left() { + return (LEFT_CHILD_TYPE) child(0); + } + + @Override + public RIGHT_CHILD_TYPE right() { + return (RIGHT_CHILD_TYPE) child(1); } @Override @@ -276,16 +270,6 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends Optional.empty(), logicalProperties, left(), right(), joinReorderContext); } - @Override - public LEFT_CHILD_TYPE left() { - return (LEFT_CHILD_TYPE) child(0); - } - - @Override - public RIGHT_CHILD_TYPE right() { - return (RIGHT_CHILD_TYPE) child(1); - } - public LogicalJoin<Plan, Plan> withHashJoinConjuncts(List<Expression> hashJoinConjuncts) { return new LogicalJoin<>( joinType, hashJoinConjuncts, this.otherJoinConjuncts, hint, left(), right(), joinReorderContext); @@ -297,7 +281,7 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends hint, left(), right(), joinReorderContext); } - public LogicalJoin<Plan, Plan> withhashJoinConjunctsAndChildren( + 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), @@ -314,4 +298,3 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends joinReorderContext); } } - --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org