cloud-fan commented on a change in pull request #26813: [SPARK-30188][SQL][WIP]
Resolve the failed unit tests when enable AQE
URL: https://github.com/apache/spark/pull/26813#discussion_r364251634
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/InsertAdaptiveSparkPlan.scala
##########
@@ -45,11 +49,45 @@ case class InsertAdaptiveSparkPlan(session: SparkSession)
extends Rule[SparkPlan
// Exchange-reuse is shared across the entire query, including sub-queries.
private val stageCache = new TrieMap[SparkPlan, QueryStageExec]()
+ private def needShuffle(plan: SparkPlan): Boolean = plan match {
+ case _: BroadcastHashJoinExec => true
+ case _: BroadcastNestedLoopJoinExec => true
+ case _: CoGroupExec => true
+ case _: GlobalLimitExec => true
+ case _: HashAggregateExec => true
+ case _: ObjectHashAggregateExec => true
+ case _: ShuffledHashJoinExec => true
+ case _: SortAggregateExec => true
+ case _: SortExec => true
+ case _: SortMergeJoinExec => true
+ case _: Exchange => true
+ case a: AdaptiveSparkPlanExec => needShuffle(a.executedPlan)
+ case _ => false
+ }
+
+ def containShuffle(plan: SparkPlan): Boolean = {
+ plan.find {
+ case p: SparkPlan if needShuffle(p) => true
+ case _ => false
+ }.isDefined
+ }
+
+ def supportAdaptiveInSubquery(plan: SparkPlan): Boolean = {
+ plan.find(_.expressions.exists(_.find {
+ case expressions.ScalarSubquery(p, _, _) =>
+ containShuffle(compileSubquery(p))
Review comment:
sorry I missed this before. I think it's too expensive to check shuffle in
subquery as we need to plan it first. We can always enable AQE when there are
subqueries, as we may have chances to optimize it, like doing constant folding
on the main query with the result of subqueries.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]