cloud-fan commented on code in PR #50402:
URL: https://github.com/apache/spark/pull/50402#discussion_r2056361492
##########
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
+ val prevPlanToRefMapping = projectList.zip(r.output).map {
+ case (fa: Alias, ta) => Alias(fa.child, ta.name)(ta.exprId)
Review Comment:
and `withName`
--
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]