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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]