mihailoale-db commented on code in PR #50325: URL: https://github.com/apache/spark/pull/50325#discussion_r2005702007
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveIdentifierClause.scala: ########## @@ -29,9 +31,29 @@ import org.apache.spark.sql.types.StringType */ object ResolveIdentifierClause extends Rule[LogicalPlan] with AliasHelper with EvalHelper { - override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUpWithPruning( - _.containsPattern(UNRESOLVED_IDENTIFIER)) { + override def apply(plan: LogicalPlan): LogicalPlan = { + val referredTempVars = new mutable.ArrayBuffer[Seq[String]] + val analyzedPlan = apply0(plan, referredTempVars) + + analyzedPlan match { + case createView: CreateView => + if (referredTempVars.nonEmpty) { + createView.copy(referredTempVars = referredTempVars.toSeq.distinct) + } else { + createView + } + case _ => analyzedPlan + } + } + + private def apply0( + plan: LogicalPlan, + referredTempVars: mutable.ArrayBuffer[Seq[String]]): LogicalPlan = + plan.resolveOperatorsUpWithPruning(_.containsPattern(UNRESOLVED_IDENTIFIER)) { case p: PlanWithUnresolvedIdentifier if p.identifierExpr.resolved && p.childrenResolved => + + referredTempVars ++= collectTemporaryVariables(p) Review Comment: Done! -- 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