maryannxue commented on a change in pull request #25600: [SPARK-11150][SQL] 
Dynamic Partition Pruning
URL: https://github.com/apache/spark/pull/25600#discussion_r319249181
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/dynamicpruning/PartitionPruning.scala
 ##########
 @@ -0,0 +1,264 @@
+/*
+ * 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.spark.sql.dynamicpruning
+
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys
+import org.apache.spark.sql.catalyst.plans._
+import org.apache.spark.sql.catalyst.plans.logical._
+import org.apache.spark.sql.catalyst.rules.Rule
+import org.apache.spark.sql.execution.datasources.{HadoopFsRelation, 
LogicalRelation}
+import org.apache.spark.sql.internal.SQLConf
+
+/**
+ * Dynamic partition pruning optimization is performed based on the type and
+ * selectivity of the join operation. During query optimization, we insert a
+ * predicate on the partitioned table using the filter from the other side of
+ * the join and a custom wrapper called DynamicPruning.
+ *
+ * The basic mechanism for DPP inserts a duplicated subquery with the filter 
from the other side,
+ * when the following conditions are met:
+ *    (1) the table to prune is partitioned by the JOIN key
+ *    (2) the join operation is one of the following types: INNER, LEFT SEMI 
(partitioned on left),
+ *    LEFT OUTER (partitioned on right), or RIGHT OUTER (partitioned on left)
+ *
+ * In order to enable partition pruning directly in broadcasts, we use a 
custom DynamicPruning
+ * clause that incorporates the In clause with the subquery and the benefit 
estimation.
+ * During query planning, when the join type is known, we use the following 
mechanism:
+ *    (1) if the join is a broadcast hash join, we replace the duplicated 
subquery with the reused
+ *    results of the broadcast,
+ *    (2) else if the estimated benefit of partition pruning outweighs the 
overhead of running the
+ *    subquery query twice, we keep the duplicated subquery
+ *    (3) otherwise, we drop the subquery.
+ */
+object PartitionPruning extends Rule[LogicalPlan] with PredicateHelper {
 
 Review comment:
   I'd agree with you on that... but it gets confusing that a lot of 
optimization rules use SQLConf.get while others use conf as a param.

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

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

Reply via email to