maropu commented on a change in pull request #29065:
URL: https://github.com/apache/spark/pull/29065#discussion_r499572935



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/dynamicpruning/PartitionPruning.scala
##########
@@ -231,18 +288,31 @@ object PartitionPruning extends Rule[LogicalPlan] with 
PredicateHelper {
 
             // there should be a partitioned table and a filter on the 
dimension table,
             // otherwise the pruning will not trigger
-            var partScan = getPartitionTableScan(l, left)
-            if (partScan.isDefined && canPruneLeft(joinType) &&
-                hasPartitionPruningFilter(right)) {
-              val hasBenefit = pruningHasBenefit(l, partScan.get, r, right)
-              newLeft = insertPredicate(l, newLeft, r, right, rightKeys, 
hasBenefit)
-            } else {
-              partScan = getPartitionTableScan(r, right)
-              if (partScan.isDefined && canPruneRight(joinType) &&
-                  hasPartitionPruningFilter(left) ) {
-                val hasBenefit = pruningHasBenefit(r, partScan.get, l, left)
-                newRight = insertPredicate(r, newRight, l, left, leftKeys, 
hasBenefit)
-              }
+            // Left side
+            getPartitionTableScan(l, left) match {
+              // partition pruning
+              case Some(partScan) if canPruneLeft(joinType) && 
hasDynamicPruningFilter(right) =>
+                val hasBenefit = pruningHasBenefit(l, partScan, r, right)
+                newLeft = insertPartitionPredicate(l, newLeft, r, right, 
rightKeys, hasBenefit)
+              // shuffle pruning
+              case None if conf.dynamicShufflePruningEnabled && 
canPruneLeft(joinType) &&
+                hasDynamicPruningFilter(right) && isDataFilter(l, left) &&
+                shufflePruningHasBenefit(l, left, r, right) =>
+                newLeft = insertShufflePredicate(l, newLeft, r, right, 
rightKeys)
+              case _ =>
+            }
+            // Right side
+            getPartitionTableScan(r, right) match {
+              // partition pruning
+              case Some(partScan) if canPruneRight(joinType) && 
hasDynamicPruningFilter(left) =>
+                val hasBenefit = pruningHasBenefit(r, partScan, l, left)
+                newRight = insertPartitionPredicate(r, newRight, l, left, 
leftKeys, hasBenefit)
+              // shuffle pruning
+              case None if conf.dynamicShufflePruningEnabled && 
canPruneRight(joinType) &&

Review comment:
       This new feature is enabled only if both 
`dynamicPartitionPruningEnabled` and `dynamicShufflePruningEnabled` are true?




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



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

Reply via email to