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 710529b060 [enhance](Nereids): refactor LogicalJoin. (#17099)
710529b060 is described below

commit 710529b06009172f4f0d4ca9f99fab9b92acbca7
Author: jakevin <[email protected]>
AuthorDate: Sun Feb 26 22:28:54 2023 +0800

    [enhance](Nereids): refactor LogicalJoin. (#17099)
---
 .../org/apache/doris/nereids/rules/RuleType.java   |  2 +-
 .../rules/exploration/join/InnerJoinLAsscom.java   | 14 ++--
 .../exploration/join/InnerJoinLAsscomProject.java  | 13 ++-
 .../exploration/join/InnerJoinLeftAssociate.java   | 14 ++--
 .../exploration/join/InnerJoinRightAssociate.java  | 14 ++--
 .../rules/exploration/join/JoinCommute.java        |  7 +-
 .../rules/exploration/join/JoinExchange.java       |  9 +-
 .../rules/exploration/join/OuterJoinAssoc.java     | 12 +--
 .../exploration/join/OuterJoinAssocProject.java    | 13 ++-
 .../rules/exploration/join/OuterJoinLAsscom.java   | 12 +--
 .../exploration/join/OuterJoinLAsscomProject.java  | 14 ++--
 .../join/SemiJoinLogicalJoinTranspose.java         | 38 +++------
 .../join/SemiJoinLogicalJoinTransposeProject.java  | 34 +++-----
 .../join/SemiJoinSemiJoinTranspose.java            | 12 +--
 .../join/SemiJoinSemiJoinTransposeProject.java     | 20 ++---
 .../nereids/trees/plans/logical/LogicalJoin.java   | 96 ++++++++--------------
 .../doris/nereids/util/LogicalPlanBuilder.java     |  5 ++
 17 files changed, 128 insertions(+), 201 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
index af6daa2efe..f69413309d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
@@ -263,7 +263,7 @@ public enum RuleType {
     LOGICAL_WINDOW_TO_PHYSICAL_WINDOW_RULE(RuleTypeClass.IMPLEMENTATION),
     IMPLEMENTATION_SENTINEL(RuleTypeClass.IMPLEMENTATION),
 
-    LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANPOSE_PROJECT(RuleTypeClass.EXPLORATION),
+    LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANSPOSE_PROJECT(RuleTypeClass.EXPLORATION),
     // sentinel, use to count rules
     SENTINEL(RuleTypeClass.SENTINEL),
     ;
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 977ef42afa..a16b7b91c1 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
@@ -23,8 +23,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
-import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.Utils;
@@ -77,15 +75,15 @@ public class InnerJoinLAsscom extends 
OneExplorationRuleFactory {
                     List<Expression> newTopOtherConjuncts = 
splitOtherConjunts.get(true);
                     List<Expression> newBottomOtherConjuncts = 
splitOtherConjunts.get(false);
 
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(JoinType.INNER_JOIN,
-                            newBottomHashConjuncts, newBottomOtherConjuncts, 
JoinHint.NONE,
-                            a, c, bottomJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newBottomJoin = 
topJoin.withConjunctsChildren(newBottomHashConjuncts,
+                            newBottomOtherConjuncts, a, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
                     newBottomJoin.getJoinReorderContext().setHasLAsscom(false);
                     newBottomJoin.getJoinReorderContext().setHasCommute(false);
 
-                    LogicalJoin<LogicalJoin<GroupPlan, GroupPlan>, GroupPlan> 
newTopJoin = new LogicalJoin<>(
-                            JoinType.INNER_JOIN, newTopHashConjuncts, 
newTopOtherConjuncts, JoinHint.NONE,
-                            newBottomJoin, b, topJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newTopJoin = 
bottomJoin.withConjunctsChildren(newTopHashConjuncts,
+                            newTopOtherConjuncts, newBottomJoin, b);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     newTopJoin.getJoinReorderContext().setHasLAsscom(true);
 
                     return newTopJoin;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscomProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscomProject.java
index aac195cb3a..bc8656520f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscomProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLAsscomProject.java
@@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.Utils;
@@ -104,18 +103,18 @@ public class InnerJoinLAsscomProject extends 
OneExplorationRuleFactory {
                     aProjects.addAll(cOutputSet);
 
                     /* ********** new Plan ********** */
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(topJoin.getJoinType(),
-                            helper.newBottomHashConjuncts, 
helper.newBottomOtherConjuncts, JoinHint.NONE,
-                            a, c, bottomJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newBottomJoin = 
topJoin.withConjunctsChildren(helper.newBottomHashConjuncts,
+                            helper.newBottomOtherConjuncts, a, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
                     newBottomJoin.getJoinReorderContext().setHasLAsscom(false);
                     newBottomJoin.getJoinReorderContext().setHasCommute(false);
 
                     Plan left = JoinReorderUtils.projectOrSelf(aProjects, 
newBottomJoin);
                     Plan right = JoinReorderUtils.projectOrSelf(bProjects, b);
 
-                    LogicalJoin<Plan, Plan> newTopJoin = new 
LogicalJoin<>(bottomJoin.getJoinType(),
-                            helper.newTopHashConjuncts, 
helper.newTopOtherConjuncts, JoinHint.NONE,
-                            left, right, topJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newTopJoin = 
bottomJoin.withConjunctsChildren(helper.newTopHashConjuncts,
+                            helper.newTopOtherConjuncts, left, right);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     newTopJoin.getJoinReorderContext().setHasLAsscom(true);
 
                     return JoinReorderUtils.projectOrSelf(new 
ArrayList<>(topJoin.getOutput()), newTopJoin);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLeftAssociate.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLeftAssociate.java
index 9a210cb91d..2f89495365 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLeftAssociate.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinLeftAssociate.java
@@ -23,8 +23,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
-import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.JoinUtils;
@@ -90,17 +88,17 @@ public class InnerJoinLeftAssociate extends 
OneExplorationRuleFactory {
                     List<Expression> newTopOtherJoinConjuncts = 
otherConjunctsSplit.get(false);
 
                     // new join.
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(JoinType.INNER_JOIN,
-                            newBottomHashJoinConjuncts, 
newBottomOtherJoinConjuncts, JoinHint.NONE,
-                            a, b, bottomJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newBottomJoin = 
topJoin.withConjunctsChildren(
+                            newBottomHashJoinConjuncts, 
newBottomOtherJoinConjuncts, a, b);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
                     newBottomJoin.getJoinReorderContext().setHasCommute(false);
                     
newBottomJoin.getJoinReorderContext().setHasRightAssociate(false);
                     
newBottomJoin.getJoinReorderContext().setHasLeftAssociate(false);
                     
newBottomJoin.getJoinReorderContext().setHasExchange(false);
 
-                    LogicalJoin<LogicalJoin<GroupPlan, GroupPlan>, GroupPlan> 
newTopJoin = new LogicalJoin<>(
-                            JoinType.INNER_JOIN, newTopHashJoinConjuncts, 
newTopOtherJoinConjuncts, JoinHint.NONE,
-                            newBottomJoin, c, topJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newTopJoin = 
bottomJoin.withConjunctsChildren(
+                            newTopHashJoinConjuncts, newTopOtherJoinConjuncts, 
newBottomJoin, c);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     
newTopJoin.getJoinReorderContext().setHasLeftAssociate(true);
                     newTopJoin.getJoinReorderContext().setHasCommute(false);
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinRightAssociate.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinRightAssociate.java
index afa307f5b1..b6ea7d2ad7 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinRightAssociate.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/InnerJoinRightAssociate.java
@@ -23,8 +23,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
-import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.JoinUtils;
@@ -88,17 +86,17 @@ public class InnerJoinRightAssociate extends 
OneExplorationRuleFactory {
                     List<Expression> newBottomOtherJoinConjuncts = 
otherConjunctsSplit.get(true);
                     List<Expression> newTopOtherJoinConjuncts = 
otherConjunctsSplit.get(false);
 
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(JoinType.INNER_JOIN,
-                            newBottomHashJoinConjuncts, 
newBottomOtherJoinConjuncts, JoinHint.NONE,
-                            b, c, bottomJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newBottomJoin = 
topJoin.withConjunctsChildren(
+                            newBottomHashJoinConjuncts, 
newBottomOtherJoinConjuncts, b, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
                     newBottomJoin.getJoinReorderContext().setHasCommute(false);
                     
newBottomJoin.getJoinReorderContext().setHasRightAssociate(false);
                     
newBottomJoin.getJoinReorderContext().setHasLeftAssociate(false);
                     
newBottomJoin.getJoinReorderContext().setHasExchange(false);
 
-                    LogicalJoin<GroupPlan, LogicalJoin<GroupPlan, GroupPlan>> 
newTopJoin = new LogicalJoin<>(
-                            JoinType.INNER_JOIN, newTopHashJoinConjuncts, 
newTopOtherJoinConjuncts, JoinHint.NONE,
-                            a, newBottomJoin, topJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newTopJoin = 
bottomJoin.withConjunctsChildren(newTopHashJoinConjuncts,
+                            newTopOtherJoinConjuncts, a, newBottomJoin);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     
newTopJoin.getJoinReorderContext().setHasRightAssociate(true);
                     newTopJoin.getJoinReorderContext().setHasCommute(false);
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
index 3c89dcd681..7b5b1c8a45 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
@@ -22,7 +22,6 @@ import org.apache.doris.nereids.rules.RuleType;
 import org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 
 import java.util.List;
@@ -52,9 +51,9 @@ public class JoinCommute extends OneExplorationRuleFactory {
                             join.getJoinType().swap(),
                             join.getHashJoinConjuncts(),
                             join.getOtherJoinConjuncts(),
-                            JoinHint.NONE,
-                            join.right(), join.left(),
-                            join.getJoinReorderContext());
+                            join.getHint(),
+                            join.right(), join.left());
+                    
newJoin.getJoinReorderContext().copyFrom(join.getJoinReorderContext());
                     newJoin.getJoinReorderContext().setHasCommute(true);
                     if (swapType == SwapType.ZIG_ZAG && isNotBottomJoin(join)) 
{
                         
newJoin.getJoinReorderContext().setHasCommuteZigZag(true);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinExchange.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinExchange.java
index 568492c3c1..e95bd2310a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinExchange.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinExchange.java
@@ -86,7 +86,8 @@ public class JoinExchange extends OneExplorationRuleFactory {
                     }
                     LogicalJoin<GroupPlan, GroupPlan> newLeftJoin = new 
LogicalJoin<>(JoinType.INNER_JOIN,
                             newLeftJoinHashJoinConjuncts, 
newLeftJoinOtherJoinConjuncts, JoinHint.NONE,
-                            a, c, leftJoin.getJoinReorderContext());
+                            a, c);
+                    
newLeftJoin.getJoinReorderContext().copyFrom(leftJoin.getJoinReorderContext());
                     newLeftJoin.getJoinReorderContext().setHasCommute(false);
                     
newLeftJoin.getJoinReorderContext().setHasLeftAssociate(false);
                     
newLeftJoin.getJoinReorderContext().setHasRightAssociate(false);
@@ -94,7 +95,8 @@ public class JoinExchange extends OneExplorationRuleFactory {
 
                     LogicalJoin<GroupPlan, GroupPlan> newRightJoin = new 
LogicalJoin<>(JoinType.INNER_JOIN,
                             newRightJoinHashJoinConjuncts, 
newRightJoinOtherJoinConjuncts, JoinHint.NONE,
-                            b, d, rightJoin.getJoinReorderContext());
+                            b, d);
+                    
newRightJoin.getJoinReorderContext().copyFrom(leftJoin.getJoinReorderContext());
                     newRightJoin.getJoinReorderContext().setHasCommute(false);
                     
newRightJoin.getJoinReorderContext().setHasLeftAssociate(false);
                     
newRightJoin.getJoinReorderContext().setHasRightAssociate(false);
@@ -103,7 +105,8 @@ public class JoinExchange extends OneExplorationRuleFactory 
{
                     LogicalJoin<LogicalJoin<GroupPlan, GroupPlan>, 
LogicalJoin<GroupPlan, GroupPlan>>
                             newTopJoin = new LogicalJoin<>(JoinType.INNER_JOIN,
                             newTopJoinHashJoinConjuncts, 
newTopJoinOtherJoinConjuncts, JoinHint.NONE,
-                            newLeftJoin, newRightJoin, 
topJoin.getJoinReorderContext());
+                            newLeftJoin, newRightJoin);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     newTopJoin.getJoinReorderContext().setHasExchange(true);
 
                     return newTopJoin;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssoc.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssoc.java
index 05229d2bcb..acb3549562 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssoc.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssoc.java
@@ -24,7 +24,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
@@ -70,13 +69,10 @@ public class OuterJoinAssoc extends 
OneExplorationRuleFactory {
                      * But because we have added eliminate_outer_rule, we 
don't need to consider this.
                      */
 
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(topJoin.getJoinType(),
-                            topJoin.getHashJoinConjuncts(), 
topJoin.getOtherJoinConjuncts(), JoinHint.NONE,
-                            b, c);
-                    LogicalJoin<GroupPlan, LogicalJoin<GroupPlan, GroupPlan>> 
newTopJoin
-                            = new LogicalJoin<>(bottomJoin.getJoinType(),
-                            bottomJoin.getHashJoinConjuncts(), 
bottomJoin.getOtherJoinConjuncts(), JoinHint.NONE,
-                            a, newBottomJoin, 
bottomJoin.getJoinReorderContext());
+                    LogicalJoin newBottomJoin = (LogicalJoin) 
topJoin.withChildren(b, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
+                    LogicalJoin newTopJoin = (LogicalJoin) 
bottomJoin.withChildren(a, newBottomJoin);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     setReorderContext(newTopJoin, newBottomJoin);
                     return newTopJoin;
                 }).toRule(RuleType.LOGICAL_OUTER_JOIN_ASSOC);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssocProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssocProject.java
index 7faafbbac5..c18d4f2383 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssocProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinAssocProject.java
@@ -24,7 +24,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.Utils;
@@ -93,16 +92,16 @@ public class OuterJoinAssocProject extends 
OneExplorationRuleFactory {
 
                     
bProjects.addAll(OuterJoinLAsscomProject.forceToNullable(c.getOutputSet()));
                     /* ********** new Plan ********** */
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(topJoin.getJoinType(),
-                            helper.newBottomHashConjuncts, 
helper.newBottomOtherConjuncts, JoinHint.NONE,
-                            b, c, bottomJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newBottomJoin = 
topJoin.withConjunctsChildren(helper.newBottomHashConjuncts,
+                            helper.newBottomOtherConjuncts, b, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
 
                     Plan left = JoinReorderUtils.projectOrSelf(aProjects, a);
                     Plan right = JoinReorderUtils.projectOrSelf(bProjects, 
newBottomJoin);
 
-                    LogicalJoin<Plan, Plan> newTopJoin = new 
LogicalJoin<>(bottomJoin.getJoinType(),
-                            helper.newTopHashConjuncts, 
helper.newTopOtherConjuncts, JoinHint.NONE,
-                            left, right, topJoin.getJoinReorderContext());
+                    LogicalJoin<Plan, Plan> newTopJoin = 
bottomJoin.withConjunctsChildren(helper.newTopHashConjuncts,
+                            helper.newTopOtherConjuncts, left, right);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     OuterJoinAssoc.setReorderContext(newTopJoin, 
newBottomJoin);
 
                     return JoinReorderUtils.projectOrSelf(new 
ArrayList<>(topJoin.getOutput()), newTopJoin);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscom.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscom.java
index a23c3f0015..acf3a7e30c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscom.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscom.java
@@ -24,7 +24,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
@@ -71,16 +70,13 @@ public class OuterJoinLAsscom extends 
OneExplorationRuleFactory {
                     GroupPlan b = bottomJoin.right();
                     GroupPlan c = topJoin.right();
 
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(topJoin.getJoinType(),
-                            topJoin.getHashJoinConjuncts(), 
topJoin.getOtherJoinConjuncts(), JoinHint.NONE,
-                            a, c, bottomJoin.getJoinReorderContext());
+                    LogicalJoin newBottomJoin = (LogicalJoin) 
topJoin.withChildren(a, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
                     newBottomJoin.getJoinReorderContext().setHasLAsscom(false);
                     newBottomJoin.getJoinReorderContext().setHasCommute(false);
 
-                    LogicalJoin<LogicalJoin<GroupPlan, GroupPlan>, GroupPlan> 
newTopJoin = new LogicalJoin<>(
-                            bottomJoin.getJoinType(),
-                            bottomJoin.getHashJoinConjuncts(), 
bottomJoin.getOtherJoinConjuncts(), JoinHint.NONE,
-                            newBottomJoin, b, topJoin.getJoinReorderContext());
+                    LogicalJoin newTopJoin = (LogicalJoin) 
bottomJoin.withChildren(newBottomJoin, b);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     newTopJoin.getJoinReorderContext().setHasLAsscom(true);
 
                     return newTopJoin;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscomProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscomProject.java
index 6bfa65b353..2562e6045a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscomProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/OuterJoinLAsscomProject.java
@@ -26,7 +26,6 @@ import 
org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.Utils;
@@ -98,19 +97,20 @@ public class OuterJoinLAsscomProject extends 
OneExplorationRuleFactory {
                     aProjects.addAll(forceToNullable(c.getOutputSet()));
 
                     /* ********** new Plan ********** */
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(topJoin.getJoinType(),
-                            helper.newBottomHashConjuncts, 
helper.newBottomOtherConjuncts, JoinHint.NONE,
-                            a, c, bottomJoin.getJoinReorderContext());
+                    LogicalJoin newBottomJoin = 
topJoin.withConjunctsChildren(helper.newBottomHashConjuncts,
+                            helper.newBottomOtherConjuncts, a, c);
+                    
newBottomJoin.getJoinReorderContext().copyFrom(bottomJoin.getJoinReorderContext());
                     newBottomJoin.getJoinReorderContext().setHasLAsscom(false);
                     newBottomJoin.getJoinReorderContext().setHasCommute(false);
 
                     Plan left = JoinReorderUtils.projectOrSelf(aProjects, 
newBottomJoin);
                     Plan right = JoinReorderUtils.projectOrSelf(bProjects, b);
 
-                    LogicalJoin<Plan, Plan> newTopJoin = new 
LogicalJoin<>(bottomJoin.getJoinType(),
-                            helper.newTopHashConjuncts, 
helper.newTopOtherConjuncts, JoinHint.NONE,
-                            left, right, topJoin.getJoinReorderContext());
+                    LogicalJoin newTopJoin = 
bottomJoin.withConjunctsChildren(helper.newTopHashConjuncts,
+                            helper.newTopOtherConjuncts, left, right);
+                    
newTopJoin.getJoinReorderContext().copyFrom(topJoin.getJoinReorderContext());
                     newTopJoin.getJoinReorderContext().setHasLAsscom(true);
+
                     return JoinReorderUtils.projectOrSelf(new 
ArrayList<>(topJoin.getOutput()), newTopJoin);
                 }).toRule(RuleType.LOGICAL_OUTER_JOIN_LASSCOM_PROJECT);
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTranspose.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTranspose.java
index 79b79510b3..cbefea40f6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTranspose.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTranspose.java
@@ -23,8 +23,8 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.util.Utils;
 
@@ -84,19 +84,11 @@ public class SemiJoinLogicalJoinTranspose extends 
OneExplorationRuleFactory {
                          *  /    \                  /    \
                          * A      B                A      C
                          */
-                        if (bottomJoin.getJoinType() == 
JoinType.RIGHT_OUTER_JOIN) {
-                            // when bottom join is right outer join, we change 
it to inner join
-                            // if we want to do this trans. However, we do not 
allow different logical properties
-                            // in one group. So we need to change it to inner 
join in rewrite step.
-                            return topSemiJoin;
-                        }
-                        LogicalJoin<GroupPlan, GroupPlan> newBottomSemiJoin = 
new LogicalJoin<>(
-                                topSemiJoin.getJoinType(),
-                                topSemiJoin.getHashJoinConjuncts(), 
topSemiJoin.getOtherJoinConjuncts(),
-                                JoinHint.NONE,
-                                a, c);
-                        return new LogicalJoin<>(bottomJoin.getJoinType(), 
bottomJoin.getHashJoinConjuncts(),
-                                bottomJoin.getOtherJoinConjuncts(), 
JoinHint.NONE, newBottomSemiJoin, b);
+                        // RIGHT_OUTER_JOIN should be eliminated in rewrite 
phase
+                        Preconditions.checkState(bottomJoin.getJoinType() != 
JoinType.RIGHT_OUTER_JOIN);
+
+                        Plan newBottomSemiJoin = topSemiJoin.withChildren(a, 
c);
+                        return bottomJoin.withChildren(newBottomSemiJoin, b);
                     } else {
                         /*
                          *    topSemiJoin            newTopJoin
@@ -105,19 +97,11 @@ public class SemiJoinLogicalJoinTranspose extends 
OneExplorationRuleFactory {
                          *  /    \                         /      \
                          * A      B                       B        C
                          */
-                        if (bottomJoin.getJoinType() == 
JoinType.LEFT_OUTER_JOIN) {
-                            // when bottom join is left outer join, we change 
it to inner join
-                            // if we want to do this trans. However, we do not 
allow different logical properties
-                            // in one group. So we need to change it to inner 
join in rewrite step.
-                            return topSemiJoin;
-                        }
-                        LogicalJoin<GroupPlan, GroupPlan> newBottomSemiJoin = 
new LogicalJoin<>(
-                                topSemiJoin.getJoinType(),
-                                topSemiJoin.getHashJoinConjuncts(), 
topSemiJoin.getOtherJoinConjuncts(),
-                                JoinHint.NONE,
-                                b, c);
-                        return new LogicalJoin<>(bottomJoin.getJoinType(), 
bottomJoin.getHashJoinConjuncts(),
-                                bottomJoin.getOtherJoinConjuncts(), 
JoinHint.NONE, a, newBottomSemiJoin);
+                        // LEFT_OUTER_JOIN should be eliminated in rewrite 
phase
+                        Preconditions.checkState(bottomJoin.getJoinType() != 
JoinType.LEFT_OUTER_JOIN);
+
+                        Plan newBottomSemiJoin = topSemiJoin.withChildren(b, 
c);
+                        return bottomJoin.withChildren(a, newBottomSemiJoin);
                     }
                 }).toRule(RuleType.LOGICAL_SEMI_JOIN_LOGICAL_JOIN_TRANSPOSE);
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTransposeProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTransposeProject.java
index 89a843fffc..aefba5aace 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTransposeProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinLogicalJoinTransposeProject.java
@@ -26,7 +26,6 @@ import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
@@ -96,19 +95,12 @@ public class SemiJoinLogicalJoinTransposeProject extends 
OneExplorationRuleFacto
                          *   /    \                    /      \
                          *  A      B                  A        C
                          */
-                        // Preconditions.checkState(bottomJoin.getJoinType() 
!= JoinType.RIGHT_OUTER_JOIN);
-                        if (bottomJoin.getJoinType() == 
JoinType.RIGHT_OUTER_JOIN) {
-                            // when bottom join is right outer join, we change 
it to inner join
-                            // if we want to do this trans. However, we do not 
allow different logical properties
-                            // in one group. So we need to change it to inner 
join in rewrite step.
-                            return null;
-                        }
-                        LogicalJoin<GroupPlan, GroupPlan> newBottomSemiJoin = 
new LogicalJoin<>(
-                                topSemiJoin.getJoinType(), conjuncts.first, 
conjuncts.second, JoinHint.NONE, a, c);
+                        // RIGHT_OUTER_JOIN should be eliminated in rewrite 
phase
+                        Preconditions.checkState(bottomJoin.getJoinType() != 
JoinType.RIGHT_OUTER_JOIN);
 
-                        LogicalJoin<Plan, Plan> newTopJoin = new 
LogicalJoin<>(bottomJoin.getJoinType(),
-                                bottomJoin.getHashJoinConjuncts(), 
bottomJoin.getOtherJoinConjuncts(),
-                                JoinHint.NONE, newBottomSemiJoin, b);
+                        Plan newBottomSemiJoin = 
topSemiJoin.withConjunctsChildren(conjuncts.first, conjuncts.second,
+                                a, c);
+                        Plan newTopJoin = 
bottomJoin.withChildren(newBottomSemiJoin, b);
                         return project.withChildren(newTopJoin);
                     } else {
                         if (leftDeep) {
@@ -123,18 +115,12 @@ public class SemiJoinLogicalJoinTransposeProject extends 
OneExplorationRuleFacto
                          *   /    \                               /      \
                          *  A      B                             B       C
                          */
-                        if (bottomJoin.getJoinType() == 
JoinType.LEFT_OUTER_JOIN) {
-                            // when bottom join is left outer join, we change 
it to inner join
-                            // if we want to do this trans. However, we do not 
allow different logical properties
-                            // in one group. So we need to change it to inner 
join in rewrite step.
-                            return null;
-                        }
-                        LogicalJoin<GroupPlan, GroupPlan> newBottomSemiJoin = 
new LogicalJoin<>(
-                                topSemiJoin.getJoinType(), conjuncts.first, 
conjuncts.second, JoinHint.NONE, b, c);
+                        // LEFT_OUTER_JOIN should be eliminated in rewrite 
phase
+                        Preconditions.checkState(bottomJoin.getJoinType() != 
JoinType.LEFT_OUTER_JOIN);
 
-                        LogicalJoin<Plan, Plan> newTopJoin = new 
LogicalJoin<>(bottomJoin.getJoinType(),
-                                bottomJoin.getHashJoinConjuncts(), 
bottomJoin.getOtherJoinConjuncts(),
-                                JoinHint.NONE, a, newBottomSemiJoin);
+                        Plan newBottomSemiJoin = 
topSemiJoin.withConjunctsChildren(conjuncts.first, conjuncts.second,
+                                b, c);
+                        Plan newTopJoin = bottomJoin.withChildren(a, 
newBottomSemiJoin);
                         return project.withChildren(newTopJoin);
                     }
                 
}).toRule(RuleType.LOGICAL_SEMI_JOIN_LOGICAL_JOIN_TRANSPOSE_PROJECT);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTranspose.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTranspose.java
index e616bc7397..f2e5c50aee 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTranspose.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTranspose.java
@@ -22,8 +22,8 @@ import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
 import org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 
 import com.google.common.collect.ImmutableSet;
@@ -69,14 +69,8 @@ public class SemiJoinSemiJoinTranspose extends 
OneExplorationRuleFactory {
                     GroupPlan b = bottomJoin.right();
                     GroupPlan c = topJoin.right();
 
-                    LogicalJoin<GroupPlan, GroupPlan> newBottomJoin = new 
LogicalJoin<>(topJoin.getJoinType(),
-                            topJoin.getHashJoinConjuncts(), 
topJoin.getOtherJoinConjuncts(), JoinHint.NONE, a, c);
-                    LogicalJoin<LogicalJoin<GroupPlan, GroupPlan>, GroupPlan> 
newTopJoin = new LogicalJoin<>(
-                            bottomJoin.getJoinType(), 
bottomJoin.getHashJoinConjuncts(),
-                            bottomJoin.getOtherJoinConjuncts(),
-                            JoinHint.NONE,
-                            newBottomJoin, b);
-
+                    Plan newBottomJoin = topJoin.withChildren(a, c);
+                    Plan newTopJoin = bottomJoin.withChildren(newBottomJoin, 
b);
                     return newTopJoin;
                 }).toRule(RuleType.LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANPOSE);
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTransposeProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTransposeProject.java
index 3e86b5b17e..734108c4db 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTransposeProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/SemiJoinSemiJoinTransposeProject.java
@@ -24,7 +24,6 @@ import 
org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
-import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
 
@@ -42,9 +41,9 @@ public class SemiJoinSemiJoinTransposeProject extends 
OneExplorationRuleFactory
 
     /*
      *        topSemi                   newTopSemi
-     *        /     \                   /        \
-     *    abProject  C               acProject    B
-     *      /            ──►          /
+     *        /     \                   /       \
+     *    aProject   C              aProject     B
+     *      |            ──►          |
      * bottomSemi                newBottomSemi
      *    /   \                     /   \
      *   A     B                   A     C
@@ -73,18 +72,17 @@ public class SemiJoinSemiJoinTransposeProject extends 
OneExplorationRuleFactory
                                         }
                                     })
                     );
-                    LogicalJoin newBottomSemi = new 
LogicalJoin<>(topSemi.getJoinType(), topSemi.getHashJoinConjuncts(),
-                            topSemi.getOtherJoinConjuncts(), JoinHint.NONE, a, 
c,
-                            bottomSemi.getJoinReorderContext());
+                    LogicalJoin newBottomSemi = (LogicalJoin) 
topSemi.withChildren(a, c);
+                    
newBottomSemi.getJoinReorderContext().copyFrom(bottomSemi.getJoinReorderContext());
                     newBottomSemi.getJoinReorderContext().setHasCommute(false);
                     newBottomSemi.getJoinReorderContext().setHasLAsscom(false);
+
                     LogicalProject acProject = new 
LogicalProject<>(Lists.newArrayList(acProjects), newBottomSemi);
-                    LogicalJoin newTopSemi = new 
LogicalJoin<>(bottomSemi.getJoinType(),
-                            bottomSemi.getHashJoinConjuncts(), 
bottomSemi.getOtherJoinConjuncts(), JoinHint.NONE,
-                            acProject, b, topSemi.getJoinReorderContext());
+                    LogicalJoin newTopSemi = (LogicalJoin) 
bottomSemi.withChildren(acProject, b);
+                    
newTopSemi.getJoinReorderContext().copyFrom(topSemi.getJoinReorderContext());
                     newTopSemi.getJoinReorderContext().setHasLAsscom(true);
                     return JoinReorderUtils.projectOrSelf(new 
ArrayList<>(topSemi.getOutput()), newTopSemi);
-                
}).toRule(RuleType.LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANPOSE_PROJECT);
+                
}).toRule(RuleType.LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANSPOSE_PROJECT);
     }
 
     public boolean 
typeChecker(LogicalJoin<LogicalProject<LogicalJoin<GroupPlan, GroupPlan>>, 
GroupPlan> topJoin) {
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 bd4f8505f6..9847c0e316 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
@@ -57,73 +57,39 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, 
RIGHT_CHILD_TYPE extends
 
     private final boolean isGenerateIsNotNull;
 
-    /**
-     * Constructor for LogicalJoinPlan.
-     *
-     * @param joinType logical type for join
-     */
     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, 
JoinReorderContext.EMPTY, false);
+                Optional.empty(), Optional.empty(), leftChild, rightChild, 
false);
     }
 
     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, 
JoinReorderContext.EMPTY, false);
-    }
-
-    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,
-                JoinReorderContext.EMPTY, false);
-    }
-
-    public LogicalJoin(
-            JoinType joinType,
-            List<Expression> hashJoinConjuncts,
-            JoinHint hint,
-            LEFT_CHILD_TYPE leftChild,
-            RIGHT_CHILD_TYPE rightChild,
-            JoinReorderContext joinReorderContext) {
-        this(joinType, hashJoinConjuncts, ExpressionUtils.EMPTY_CONDITION, 
hint,
-                Optional.empty(), Optional.empty(), leftChild, rightChild, 
joinReorderContext, false);
-    }
-
-    public LogicalJoin(
-            JoinType joinType,
-            List<Expression> hashJoinConjuncts,
-            List<Expression> otherJoinConjuncts,
-            JoinHint hint,
-            LEFT_CHILD_TYPE leftChild,
-            RIGHT_CHILD_TYPE rightChild,
-            JoinReorderContext joinReorderContext) {
-        this(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, 
Optional.empty(), Optional.empty(), leftChild,
-                rightChild, joinReorderContext, false);
+                Optional.empty(), leftChild, rightChild, false);
     }
 
-    public LogicalJoin(
-            JoinType joinType,
-            List<Expression> hashJoinConjuncts,
-            List<Expression> otherJoinConjuncts,
-            JoinHint hint,
-            LEFT_CHILD_TYPE leftChild,
-            RIGHT_CHILD_TYPE rightChild,
-            JoinReorderContext joinReorderContext,
-            boolean isGenerateIsNotNull) {
+    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, joinReorderContext, isGenerateIsNotNull);
+                rightChild, false);
     }
 
     /**
-     * Constructor for LogicalJoinPlan.
+     * Just use in withXXX method.
      */
-    public LogicalJoin(
+    private LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts, 
List<Expression> otherJoinConjuncts,
+            JoinHint hint, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE 
rightChild,
+            JoinReorderContext joinReorderContext, boolean 
isGenerateIsNotNull) {
+        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);
+    }
+
+    private LogicalJoin(
             JoinType joinType,
             List<Expression> hashJoinConjuncts,
             List<Expression> otherJoinConjuncts,
@@ -132,14 +98,12 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, 
RIGHT_CHILD_TYPE extends
             Optional<LogicalProperties> logicalProperties,
             LEFT_CHILD_TYPE leftChild,
             RIGHT_CHILD_TYPE rightChild,
-            JoinReorderContext joinReorderContext,
             boolean isGenerateIsNotNull) {
         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);
         this.isGenerateIsNotNull = isGenerateIsNotNull;
     }
 
@@ -244,14 +208,18 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, 
RIGHT_CHILD_TYPE extends
 
     @Override
     public LogicalJoin<Plan, Plan> 
withGroupExpression(Optional<GroupExpression> groupExpression) {
-        return new LogicalJoin<>(joinType, hashJoinConjuncts, 
otherJoinConjuncts, hint, groupExpression,
-                Optional.of(getLogicalProperties()), left(), right(), 
joinReorderContext, isGenerateIsNotNull);
+        LogicalJoin<Plan, Plan> newJoin = new LogicalJoin<>(joinType, 
hashJoinConjuncts, otherJoinConjuncts, hint,
+                groupExpression, Optional.of(getLogicalProperties()), left(), 
right(), isGenerateIsNotNull);
+        newJoin.getJoinReorderContext().copyFrom(this.getJoinReorderContext());
+        return newJoin;
     }
 
     @Override
     public LogicalJoin<Plan, Plan> 
withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
-        return new LogicalJoin<>(joinType, hashJoinConjuncts, 
otherJoinConjuncts, hint, Optional.empty(),
-                logicalProperties, left(), right(), joinReorderContext, 
isGenerateIsNotNull);
+        LogicalJoin<Plan, Plan> newJoin = new LogicalJoin<>(joinType, 
hashJoinConjuncts, otherJoinConjuncts, hint,
+                Optional.empty(), logicalProperties, left(), right(), 
isGenerateIsNotNull);
+        newJoin.getJoinReorderContext().copyFrom(this.getJoinReorderContext());
+        return newJoin;
     }
 
     public LogicalJoin<Plan, Plan> withHashJoinConjuncts(List<Expression> 
hashJoinConjuncts) {
@@ -272,6 +240,12 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, 
RIGHT_CHILD_TYPE extends
                 children.get(1), joinReorderContext, isGenerateIsNotNull);
     }
 
+    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);
+    }
+
     public LogicalJoin<Plan, Plan> withJoinType(JoinType joinType) {
         return new LogicalJoin<>(joinType, hashJoinConjuncts, 
otherJoinConjuncts, hint, left(), right(),
                 joinReorderContext, isGenerateIsNotNull);
@@ -284,7 +258,7 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, 
RIGHT_CHILD_TYPE extends
 
     public LogicalJoin<Plan, Plan> withIsGenerateIsNotNullAndChildren(boolean 
isGenerateIsNotNull,
             Plan left, Plan right) {
-        return new LogicalJoin<>(joinType, hashJoinConjuncts, 
otherJoinConjuncts, hint, Optional.empty(),
-                Optional.empty(), left, right, joinReorderContext, 
isGenerateIsNotNull);
+        return new LogicalJoin<>(joinType, hashJoinConjuncts, 
otherJoinConjuncts, hint, left,
+                right, joinReorderContext, isGenerateIsNotNull);
     }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
index 04da2c6bae..c719302ac5 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
@@ -73,6 +73,11 @@ public class LogicalPlanBuilder {
         return from(project);
     }
 
+    public LogicalPlanBuilder projectExprs(List<NamedExpression> projectExprs) 
{
+        LogicalProject<LogicalPlan> project = new 
LogicalProject<>(projectExprs, this.plan);
+        return from(project);
+    }
+
     public LogicalPlanBuilder alias(List<Integer> slotsIndex, List<String> 
alias) {
         Preconditions.checkArgument(slotsIndex.size() == alias.size());
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to