liuzqt commented on code in PR #49715:
URL: https://github.com/apache/spark/pull/49715#discussion_r1944184777


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/AdaptiveSparkPlanExec.scala:
##########
@@ -579,23 +592,52 @@ case class AdaptiveSparkPlanExec(
         allChildStagesMaterialized = false,
         newStages = Seq(newStage))
 
-    case q: QueryStageExec =>
+    case q: QueryStageExec if q ne currentPhysicalPlan =>

Review Comment:
   We can have plan like this:
   ```
   ShuffleQueryStage 0
   +- Exchange hashpartitioning(key#17, 5), REPARTITION_BY_COL, [plan_id=89]
      +- *(1) SerializeFromObject [invoke(knownnotnull(assertnotnull(input[0, 
org.apache.spark.sql.test.SQLTestData$TestData, true])).key()) AS key#17, 
static_invoke(UTF8String.fromString(invoke(knownnotnull(assertnotnull(input[0, 
org.apache.spark.sql.test.SQLTestData$TestData, true])).value()))) AS value#18]
         +- Scan[obj#14]
   ``` 
   
   where the root plan is a `ShuffleQueryStageExec` and we have to create a 
ResultQueryStage on top of it.
   ==> 
   ```
   ResultQueryStage 1
   +- AQEShuffleRead coalesced
      +- ShuffleQueryStage 0
         +- Exchange hashpartitioning(key#17, 5), REPARTITION_BY_COL, 
[plan_id=89]
            +- *(1) SerializeFromObject 
[invoke(knownnotnull(assertnotnull(input[0, 
org.apache.spark.sql.test.SQLTestData$TestData, true])).key()) AS key#17, 
static_invoke(UTF8String.fromString(invoke(knownnotnull(assertnotnull(input[0, 
org.apache.spark.sql.test.SQLTestData$TestData, true])).value()))) AS value#18]
               +- S...
   ```
   
   This refactor is equivalent to my previous implementation using 
`createQueryStagesInternal` and create result stage in the external 
`createQueryStages`



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to