cloud-fan commented on a change in pull request #31258:
URL: https://github.com/apache/spark/pull/31258#discussion_r561945532
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/InsertAdaptiveSparkPlan.scala
##########
@@ -129,6 +129,33 @@ case class InsertAdaptiveSparkPlan(
verifyAdaptivePlan(executedPlan, query)
val subquery = SubqueryExec(s"subquery#${exprId.id}", executedPlan)
subqueryMap.put(exprId.id, subquery)
+ case expressions.DynamicPruningSubquery(value, buildPlan,
+ buildKeys, broadcastKeyIndex, onlyInBroadcast, exprId)
+ if !subqueryMap.contains(exprId.id) =>
+ val executedPlan = compileSubquery(buildPlan)
+ verifyAdaptivePlan(executedPlan, buildPlan)
+ val adaptivePlan = executedPlan.asInstanceOf[AdaptiveSparkPlanExec]
+
+ // Insert the broadcast exchange
+ val packedKeys =
+ BindReferences.bindReferences(HashJoin.rewriteKeyExpr(buildKeys),
+ adaptivePlan.inputPlan.output)
+ val mode = HashedRelationBroadcastMode(packedKeys)
+ // plan a broadcast exchange of the build side of the join
+ val exchange = BroadcastExchangeExec(mode, adaptivePlan.inputPlan)
+ val name = s"dynamicpruning#${exprId.id}"
+
+ // place the broadcast adaptor for reusing the broadcast results on
the probe side
+ val broadcastValues =
+ SubqueryBroadcastExec(name, broadcastKeyIndex, buildKeys, exchange)
+
+ // Update the inputPlan and the currentPhysicalPlan of the
adaptivePlan.
+ adaptivePlan.inputPlan = broadcastValues
Review comment:
can we wrap the `adaptivePlan` with subquery broadcast? Then we don't
need to mutate `adaptivePlan.inputPlan` annd keep it as immutable.
----------------------------------------------------------------
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]