hvanhovell commented on code in PR #44162:
URL: https://github.com/apache/spark/pull/44162#discussion_r1416043099


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -3469,6 +3470,52 @@ class Analyzer(override val catalogManager: 
CatalogManager) extends RuleExecutor
     }
   }
 
+  /**
+   * Rewrite [[UnresolvedWithColumns]] into a [[Project]].
+   *
+   * `withColumns` can both update an existing columns and add new columns.
+   */
+  object RewriteWithColumns extends Rule[LogicalPlan] {
+    override def apply(plan: LogicalPlan): LogicalPlan = 
plan.resolveOperatorsWithPruning(
+      _.containsPattern(UNRESOLVED_WITH_COLUMNS), ruleId) {
+      case UnresolvedWithColumns(projectList, child) if child.resolved =>
+        SchemaUtils.checkColumnNameDuplication(
+          projectList.map(_.name),
+          resolver)
+        val usedProjectListIndices = mutable.Set.empty[Int]
+        val outputProjectListBuilder = Seq.newBuilder[NamedExpression]
+        val lookup = {

Review Comment:
   I am not sure how that would work. We only know the appended columns if we 
have seen all existing columns.



-- 
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

Reply via email to