You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/24 01:52:13 UTC

[GitHub] [spark] weixiuli commented on a change in pull request #31941: [SPARK-34637][SQL] Improve the performance of AQE and DPP through logical optimization.

weixiuli commented on a change in pull request #31941:
URL: https://github.com/apache/spark/pull/31941#discussion_r600097251



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/PlanAdaptiveDynamicPruningFilters.scala
##########
@@ -39,21 +55,51 @@ case class PlanAdaptiveDynamicPruningFilters(
       case DynamicPruningExpression(InSubqueryExec(
           value, SubqueryAdaptiveBroadcastExec(name, index, buildKeys,
           adaptivePlan: AdaptiveSparkPlanExec), exprId, _)) =>
+        val currentPhysicalPlan = adaptivePlan.executedPlan
         val packedKeys = BindReferences.bindReferences(
-          HashJoin.rewriteKeyExpr(buildKeys), adaptivePlan.executedPlan.output)
-        val mode = HashedRelationBroadcastMode(packedKeys)
-        // plan a broadcast exchange of the build side of the join
-        val exchange = BroadcastExchangeExec(mode, adaptivePlan.executedPlan)
-        val existingStage = stageCache.get(exchange.canonicalized)
-        if (existingStage.nonEmpty && conf.exchangeReuseEnabled) {
-          val name = s"dynamicpruning#${exprId.id}"
-          val reuseQueryStage = existingStage.get.newReuseInstance(0, exchange.output)
-          val broadcastValues =
-            SubqueryBroadcastExec(name, index, buildKeys, reuseQueryStage)
-          DynamicPruningExpression(InSubqueryExec(value, broadcastValues, exprId))
+          HashJoin.rewriteKeyExpr(buildKeys), currentPhysicalPlan.output)
+        val canReuseExchange = conf.exchangeReuseEnabled && buildKeys.nonEmpty &&
+          hasBroadcastHashJoinExec(currentPhysicalPlan)
+
+        logDebug(s"PlanAdaptiveDynamicPruningFilters: canReuseExchange => $canReuseExchange " +
+          s"currentPhysicalPlan => ${currentPhysicalPlan}  " +
+          s"plan => $plan")
+
+        var dynamicPruningExpression = DynamicPruningExpression(Literal.TrueLiteral)
+        if (canReuseExchange) {
+          val mode = HashedRelationBroadcastMode(packedKeys)
+          // plan a broadcast exchange of the build side of the join
+          val exchange = BroadcastExchangeExec(mode, currentPhysicalPlan)
+          val existingStage = stageCache.get(exchange.canonicalized)
+          val broadcastQueryStage = if (existingStage.isDefined) {
+            val reuseQueryStage = adaptivePlan.reuseQueryStage(existingStage.get, exchange)
+            logDebug(s"PlanAdaptiveDynamicPruningFilters: reuseQueryStage => $reuseQueryStage")
+            Option(reuseQueryStage)
+          } else if (conf.dynamicPartitionPruningCreateBroadcastEnabled) {

Review comment:
       Thank you for your time. Yes, we may keep it now for reviewing and remove it finally.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org