imback82 commented on a change in pull request #33200: URL: https://github.com/apache/spark/pull/33200#discussion_r672489238
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ########## @@ -3574,15 +3568,64 @@ class Analyzer(override val catalogManager: CatalogManager) /** * Rule to mostly resolve, normalize and rewrite column names based on case sensitivity - * for alter table commands. + * for alter table column commands. */ - object ResolveAlterTableCommands extends Rule[LogicalPlan] { + object ResolveAlterTableColumnCommands extends Rule[LogicalPlan] { def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUp { - case a: AlterTableCommand if a.table.resolved && hasUnresolvedFieldName(a) => + case a: AlterTableColumnCommand if a.table.resolved && hasUnresolvedFieldName(a) => val table = a.table.asInstanceOf[ResolvedTable] a.transformExpressions { - case u: UnresolvedFieldName => resolveFieldNames(table, u.name, u) + case u: UnresolvedFieldName => resolveFieldNames(table, u.name, u.origin) + } + + case a @ AlterTableAddColumns(r: ResolvedTable, cols) if hasUnresolvedColumns(cols) => Review comment: Note that since column name is `Seq[String]` this can be resolved many times if the column's position is None (e.g, `hasUnresolvedColumns` doesn't consider `QualifiedColType.name`: ``` private def hasUnresolvedColumns(cols: Seq[QualifiedColType]): Boolean = { cols.exists(_.position.forall(!_.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