cloud-fan commented on code in PR #49351: URL: https://github.com/apache/spark/pull/49351#discussion_r1914412440
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveWithCTE.scala: ########## @@ -41,19 +43,102 @@ object ResolveWithCTE extends Rule[LogicalPlan] { plan: LogicalPlan, cteDefMap: mutable.HashMap[Long, CTERelationDef]): LogicalPlan = { plan.resolveOperatorsDownWithPruning(_.containsAllPatterns(CTE)) { - case w @ WithCTE(_, cteDefs) => - cteDefs.foreach { cteDef => - if (cteDef.resolved) { - cteDefMap.put(cteDef.id, cteDef) - } + case withCTE @ WithCTE(_, cteDefs) => + val newCTEDefs = cteDefs.map { + case cteDef if !cteDef.recursive => + val newCTEDef = cteDef + if (newCTEDef.resolved) { + cteDefMap.put(newCTEDef.id, newCTEDef) + } + newCTEDef Review Comment: ```suggestion if (cteDef.resolved) { cteDefMap.put(cteDef.id, cteDef) } cteDef ``` -- 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