englefly commented on code in PR #12571:
URL: https://github.com/apache/doris/pull/12571#discussion_r970915323


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java:
##########
@@ -53,9 +57,14 @@ public class RuleSet {
             .add(new MergeConsecutiveProjects())
             .build();
 
-    public static final List<Rule> REWRITE_RULES = planRuleFactories()
-            .add(new AggregateDisassemble())
-            .build();
+    public static final List<RuleFactory> PUSH_DOWN_JOIN_CONDITION_RULES = 
ImmutableList.of(
+            new PushDownJoinOtherCondition(),

Review Comment:
   It is better to add one rule: filter->project transform to project->filter
   because after transform subquery to join, we have  pattern: 
filter->project->join. 
   



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownJoinOtherCondition.java:
##########
@@ -0,0 +1,97 @@
+// 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.rewrite.logical;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.rules.rewrite.OneRewriteRuleFactory;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+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.ExpressionUtils;
+import org.apache.doris.nereids.util.PlanUtils;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Push the other join conditions in LogicalJoin to children.
+ */
+public class PushDownJoinOtherCondition extends OneRewriteRuleFactory {
+    private static final ImmutableList<JoinType> PUSH_DOWN_LEFT_VALID_TYPE = 
ImmutableList.of(
+            JoinType.INNER_JOIN,
+            JoinType.RIGHT_OUTER_JOIN,
+            JoinType.RIGHT_ANTI_JOIN,
+            JoinType.RIGHT_SEMI_JOIN,
+            JoinType.CROSS_JOIN
+    );
+
+    private static final ImmutableList<JoinType> PUSH_DOWN_RIGHT_VALID_TYPE = 
ImmutableList.of(
+            JoinType.INNER_JOIN,
+            JoinType.LEFT_OUTER_JOIN,
+            JoinType.LEFT_ANTI_JOIN,
+            JoinType.LEFT_SEMI_JOIN,

Review Comment:
   consider this sql:
   `L left semi join R on La=Ra and Lb>1`
   `Lb>1` could be pushed down to `scan(L)`
   LEFT_SEMI_JOIN should be in PUSH_DOWN_LEFT_VALID_TYPE



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to