JkSelf commented on a change in pull request #32861:
URL: https://github.com/apache/spark/pull/32861#discussion_r670309053



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/PlanAdaptiveDynamicPruningFilters.scala
##########
@@ -62,8 +63,18 @@ case class PlanAdaptiveDynamicPruningFilters(
           val broadcastValues = SubqueryBroadcastExec(
             name, index, buildKeys, newAdaptivePlan)
           DynamicPruningExpression(InSubqueryExec(value, broadcastValues, 
exprId))
-        } else {
+        } else if (onlyInBroadcast) {
           DynamicPruningExpression(Literal.TrueLiteral)
+        } else {
+          // we need to apply an aggregate on the buildPlan in order to be 
column pruned
+          val alias = Alias(buildKeys(index), buildKeys(index).toString)()
+          val aggregate = Aggregate(Seq(alias), Seq(alias), buildPlan)
+
+          val session = adaptivePlan.context.session
+          val sparkPlan = 
session.sessionState.planner.plan(ReturnAnswer(aggregate)).next()

Review comment:
       Here we can not use the `QueryExecution.prepareExecutedPlan()` method, 
which will cause the wholestage code gen be inserted twice.




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

To unsubscribe, e-mail: [email protected]

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