cloud-fan commented on code in PR #50402:
URL: https://github.com/apache/spark/pull/50402#discussion_r2056359712


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/UnionLoopExec.scala:
##########
@@ -149,6 +156,33 @@ case class UnionLoopExec(
     val numPartitions = prevDF.queryExecution.toRdd.partitions.length
     // Main loop for obtaining the result of the recursive query.
     while (prevCount > 0 && !limitReached) {
+      var prevPlan: LogicalPlan = null
+      // the current plan is created by substituting UnionLoopRef node with 
the project node of
+      // the previous plan.
+      // This way we support only UNION ALL case. Additional case should be 
added for UNION case.
+      // One way of supporting UNION case can be seen at SPARK-24497 PR from 
Peter Toth.
+      val newRecursion = recursion.transform {
+        case r: UnionLoopRef if r.loopId == loopId =>
+          prevDF.queryExecution.optimizedPlan match {
+            case l: LocalRelation =>
+              prevPlan = prevDF.queryExecution.optimizedPlan
+              l.copy(output = r.output)
+            case p @ Project(projectList, _: OneRowRelation) =>
+              prevPlan = prevDF.queryExecution.optimizedPlan

Review Comment:
   ```suggestion
                 prevPlan = p
   ```



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