imback82 commented on a change in pull request #33200:
URL: https://github.com/apache/spark/pull/33200#discussion_r673291583
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -1025,17 +938,23 @@ trait CheckAnalysis extends PredicateHelper with
LookupCatalog {
/**
* Validates the options used for alter table commands after table and
columns are resolved.
*/
- private def checkAlterTableCommand(alter: AlterTableCommand): Unit = {
- def checkColumnNotExists(fieldNames: Seq[String], struct: StructType):
Unit = {
+ private def checkAlterTableColumnCommand(alter: AlterTableColumnCommand):
Unit = {
+ def checkColumnNotExists(op: String, fieldNames: Seq[String], struct:
StructType): Unit = {
if (struct.findNestedField(fieldNames, includeCollections =
true).isDefined) {
- alter.failAnalysis(s"Cannot ${alter.operation} column, because
${fieldNames.quoted} " +
+ alter.failAnalysis(s"Cannot $op column, because ${fieldNames.quoted} "
+
s"already exists in ${struct.treeString}")
}
}
alter match {
+ case AlterTableAddColumns(table: ResolvedTable, colsToAdd) =>
+ colsToAdd.foreach { colToAdd =>
+ checkColumnNotExists("add", colToAdd.name, table.schema)
Review comment:
Also, if this is a bug, will the fix be ported to 3.2?
I am not sure whether this PR will be ported to 3.2, so I need to know
whether the fix should come before or after this PR.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]