godfreyhe commented on a change in pull request #8440: [FLINK-12509] 
[table-planner-blink] Introduce planner rules about non semi/anti join
URL: https://github.com/apache/flink/pull/8440#discussion_r286016634
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/rules/logical/JoinDependentConditionPushDownRule.scala
 ##########
 @@ -0,0 +1,139 @@
+/*
+ * 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.flink.table.plan.rules.logical
+
+import org.apache.flink.table.plan.util.FlinkRexUtil
+
+import org.apache.calcite.plan.RelOptRule.{any, operand}
+import org.apache.calcite.plan.{RelOptRule, RelOptRuleCall, RelOptUtil}
+import org.apache.calcite.rel.core.Join
+import org.apache.calcite.rel.logical.LogicalJoin
+import org.apache.calcite.rex.RexNode
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+  * Planner Rule that extracts some sub-conditions in the Join OR condition 
that can be pushed
+  * into join inputs by [[FlinkFilterJoinRule]].
+  *
+  * <p>For example, there is a join query (table A join table B):
+  * {{{
+  * SELECT * FROM A, B WHERE A.f1 = B.f1 AND ((A.f2 = 'aaa1' AND B.f2 = 
'bbb1') OR
+  * (A.f2 = 'aaa2' AND B.f2 = 'bbb2'))
+  * }}}
+  *
+  * <p>Hence the query rewards optimizers that can analyze complex join 
conditions which cannot be
+  * pushed below the join, but still derive filters from such join conditions. 
It could immediately
+  * filter the scan(A) with the condition: (A.f2 = 'aaa1' OR A.f2 = 'aaa2').
+  *
+  * <p>After join condition dependent optimization, the query will be:
+  * {{{
+  * SELECT * FROM A, B WHERE A.f1 = B.f1 AND
+  * ((A.f2 = 'aaa1' AND B.f2 = 'bbb1') OR (A.f2 = 'aaa2' AND B.f2 = 'bbb2'))
+  * AND (A.f2 = 'aaa1' OR A.f2 = 'aaa2') AND (B.f2 = 'bbb1' OR B.f2 = 'bbb2')
+  * }}}.
+  *
+  * <p>Note: This class can only be used in HepPlanner with RULE_SEQUENCE.
+  */
+class JoinDependentConditionPushDownRule
 
 Review comment:
   yes, this rule just derives dependent join condition, and `FilterJoinRule` 
will push down the join condition into its inputs. I think 
JoinDependentConditionDerivationRule is better.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to