You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/05/17 08:38:36 UTC

[GitHub] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9598: [feature](nereids): add join rules base code

EmmyMiao87 commented on code in PR #9598:
URL: https://github.com/apache/incubator-doris/pull/9598#discussion_r874531016


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommutative.java:
##########
@@ -15,28 +15,43 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package org.apache.doris.nereids.rules.exploration;
+package org.apache.doris.nereids.rules.exploration.join;
 
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
-import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 
 /**
  * rule factory for exchange inner join's children.
  */
 public class JoinCommutative extends OneExplorationRuleFactory {
+    private boolean justApplyInnerOuterCrossJoin = false;
+
+    private final SwapType swapType;
+
+    /**
+     * If param is true, just apply rule in inner/full-outer/cross join.
+     */
+    public JoinCommutative(boolean justApplyInnerOuterCrossJoin) {
+        this.justApplyInnerOuterCrossJoin = justApplyInnerOuterCrossJoin;
+        this.swapType = SwapType.ALL;

Review Comment:
   What's this used for ?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinExchange.java:
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.exploration.join;
+
+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.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+
+/**
+ * For busy-tree, exchange the children node.
+ */
+public class JoinExchange extends OneExplorationRuleFactory {
+    /*
+     *        topJoin                      newTopJoin
+     *        /      \                      /      \
+     *   leftJoin  rightJoin   -->   newLeftJoin newRightJoin
+     *    /    \    /    \            /    \        /    \
+     *   A      B  C      D          A      C      B      D
+     */
+    @Override
+    public Rule<Plan> build() {
+        return innerLogicalJoin(innerLogicalJoin(), any()).then(topJoin -> {

Review Comment:
   Is it correct?
   Maybe it should be ```innerLogicalJoin(innerLogicalJoin(), innerLogicalJoin()) ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommutative.java:
##########
@@ -15,28 +15,43 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package org.apache.doris.nereids.rules.exploration;
+package org.apache.doris.nereids.rules.exploration.join;
 
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
-import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.rules.exploration.OneExplorationRuleFactory;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 
 /**
  * rule factory for exchange inner join's children.
  */
 public class JoinCommutative extends OneExplorationRuleFactory {

Review Comment:
   Could you please add some unit test for those rule ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org