924060929 commented on code in PR #11531:
URL: https://github.com/apache/doris/pull/11531#discussion_r937932907


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/lasscom/InnerLeftOuterJoinLAsscom.java:
##########
@@ -0,0 +1,54 @@
+// 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.lasscom;
+
+import org.apache.doris.nereids.annotation.Developing;
+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.logical.LogicalJoin;
+
+/**
+ * Rule for change inner join left associative to right.
+ */
+@Developing
+public class InnerLeftOuterJoinLAsscom extends OneExplorationRuleFactory {
+    /*
+     *      topJoin                newTopJoin
+     *      /     \                 /     \
+     * bottomJoin  C   -->  newBottomJoin  B
+     *  /    \                  /    \
+     * A      B                A      C
+     */
+    @Override
+    public Rule build() {
+        return innerLogicalJoin(leftOuterLogicalJoin(groupPlan(), 
groupPlan()), groupPlan())
+            .when(LAsscomHelper::check)
+            .then(topJoin -> {
+
+                LogicalJoin<GroupPlan, GroupPlan> bottomJoin = topJoin.left();
+                LAsscomHelper helper = LAsscomHelper.of(topJoin, bottomJoin);

Review Comment:
   seems the logic is same whatever the join type is.
   if join type does not matter, you can set the pattern to
   ```java
   logicalJoin(logicalJoin(), groupPlan())
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/lasscom/InnerInnerJoinLAsscom.java:
##########
@@ -0,0 +1,54 @@
+// 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.lasscom;
+
+import org.apache.doris.nereids.annotation.Developing;
+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.logical.LogicalJoin;
+
+/**
+ * Rule for change inner join left associative to right.
+ */
+@Developing
+public class InnerInnerJoinLAsscom extends OneExplorationRuleFactory {
+    /*
+     *      topJoin                newTopJoin
+     *      /     \                 /     \
+     * bottomJoin  C   -->  newBottomJoin  B
+     *  /    \                  /    \
+     * A      B                A      C
+     */
+    @Override
+    public Rule build() {
+        return innerLogicalJoin(innerLogicalJoin(groupPlan(), groupPlan()), 
groupPlan())

Review Comment:
   a non-leaf pattern's children is default groupPlan. so you can simplify to:
   ```java
   innerLogicalJoin(innerLogicalJoin(), groupPlan())
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/lasscom/InnerProjectInnerJoinLAsscom.java:
##########
@@ -0,0 +1,58 @@
+// 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.lasscom;
+
+import org.apache.doris.nereids.annotation.Developing;
+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.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+
+/**
+ * Rule for change inner join left associative to right.
+ */
+@Developing
+public class InnerProjectInnerJoinLAsscom extends OneExplorationRuleFactory {
+    /*
+     *        topJoin                   newTopJoin
+     *        /     \                   /        \
+     *    project    C          newLeftProject newRightProject
+     *      /            ──►          /            \
+     * bottomJoin                newBottomJoin      B
+     *    /   \                     /   \
+     *   A     B                   A     C
+     */
+    @Override
+    public Rule build() {
+        return innerLogicalJoin(logicalProject(innerLogicalJoin(groupPlan(), 
groupPlan())), groupPlan())
+            .when(LAsscomHelper::check)
+            .then(topJoin -> {
+                LogicalProject<LogicalJoin<GroupPlan, GroupPlan>> project = 
topJoin.left();
+                LogicalJoin<GroupPlan, GroupPlan> bottomJoin = project.child();
+
+                LAsscomHelper helper = LAsscomHelper.of(topJoin, bottomJoin);
+                if (!helper.initJoinOnCondition()) {
+                    return null;
+                }
+
+                return helper.newProjectTopJoin();

Review Comment:
   forgot to process split project project?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to