cloud-fan commented on code in PR #47180: URL: https://github.com/apache/spark/pull/47180#discussion_r1666181528
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CollectCTEDefinitions.scala: ########## @@ -282,11 +283,15 @@ object CTESubstitution extends Rule[LogicalPlan] { if (alwaysInline) { d.child } else { - // Add a `SubqueryAlias` for hint-resolving rules to match relation names. - SubqueryAlias(table, CTERelationRef(d.id, d.resolved, d.output, d.isStreaming)) + // Add unresolved with CTE relations to the plan and we + // will do CTE resolution later in analyzer based on this node. + UnresolvedWithCTERelations(u, cteRelations) } }.getOrElse(u) + case p: PlanWithUnresolvedIdentifier => Review Comment: Let's keep the rule name unchanged and only make this change here. We should also add comments to explain it ``` // We must look up CTE relations first when resolving `UnresolvedRelation`s, but we can't do it here // as `PlanWithUnresolvedIdentifier` is a leaf node and may produce `UnresolvedRelation` later. Here // we wrap it with `UnresolvedWithCTERelations` so that we can delay the CTE relations lookup after // `PlanWithUnresolvedIdentifier` is resolved. ``` -- 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