suibianwanwank commented on code in PR #3381:
URL: https://github.com/apache/calcite/pull/3381#discussion_r1307102565


##########
core/src/main/java/org/apache/calcite/plan/expand/ExpandJoinOnRightCalcToJoinUnifyRule.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.calcite.plan.expand;
+
+import org.apache.calcite.plan.SubstitutionVisitor;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.mutable.MutableCalc;
+import org.apache.calcite.rel.mutable.MutableJoin;
+import org.apache.calcite.rel.mutable.MutableRel;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexProgram;
+import org.apache.calcite.rex.RexShuttle;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.util.Pair;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.calcite.plan.SubstitutionVisitor.explainCalc;
+import static org.apache.calcite.plan.SubstitutionVisitor.splitFilter;
+import static 
org.apache.calcite.plan.expand.JoinRexUtils.addJoinDerivePredicate;
+import static org.apache.calcite.plan.expand.JoinRexUtils.extractJoinContext;
+import static org.apache.calcite.plan.expand.JoinRexUtils.isJoinRewritable;
+import static org.apache.calcite.plan.expand.JoinRexUtils.isSupportedPredict;
+import static org.apache.calcite.plan.expand.JoinRexUtils.tryCastRexInputRef;
+import static 
org.apache.calcite.plan.expand.SubstitutionRuleUtils.canPullUpFilterUnderJoin;
+import static org.apache.calcite.plan.expand.SubstitutionRuleUtils.fieldCnt;
+import static 
org.apache.calcite.plan.expand.SubstitutionRuleUtils.referenceByMapping;
+import static 
org.apache.calcite.plan.expand.SubstitutionRuleUtils.tryMergeParentCalcAndGenResult;
+
+/**
+ * Enhancements to joinOnRightCalcToJoinUnifyRule.
+ */
+public class ExpandJoinOnRightCalcToJoinUnifyRule

Review Comment:
   You can see that there are prototypes of these three rules in the rules that 
already exist in SubstitutionVisitor, because the unifyRule is an adaptation of 
the operator to the operator level, so different input structures of Join are 
treated differently, which you can also reflect in  tests
   For example, the following two SQL statements correspond to JoinOnLeftCal 
and JoinOnRightCal, respectively
   `       select A.empid, A.deptno, depts.deptno from
             (select empid, deptno from emps where deptno > 10) A
             join depts
            on A.deptno = depts.deptno ;
   `
   `       select A.empid, A.deptno, depts.deptno from
            depts
             join  (select empid, deptno from emps where deptno > 10) A
            on depts.deptno =  A.deptno ;
   `



-- 
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]

Reply via email to