Pajaraja commented on code in PR #50546: URL: https://github.com/apache/spark/pull/50546#discussion_r2039960513
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveWithCTE.scala: ########## @@ -83,8 +83,21 @@ object ResolveWithCTE extends Rule[LogicalPlan] { cteDef.copy(child = alias.copy(child = loop)) } + // Simple case of duplicating (UNION ALL) clause, with CTEs inside. + case alias @ SubqueryAlias(_, withCTE @ WithCTE( + Union(Seq(anchor, recursion), false, false), _)) => Review Comment: Actually we do, yes! Since these CTEs refer to the whole inside of the initial CTE an can be called from the recursion we need to add logic to replace CteRelationRef with UnionLoopRef inside of these CTEs (and not just inside of the recursion). I've changed this now and added some tests to test it. -- 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