cloud-fan commented on a change in pull request #33113:
URL: https://github.com/apache/spark/pull/33113#discussion_r663721254



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -1088,8 +1058,51 @@ trait CheckAnalysis extends PredicateHelper with 
LookupCatalog {
     }
 
     alter match {
-      case AlterTableRenameColumn(table: ResolvedTable, 
ResolvedFieldName(name), newName) =>
-        checkColumnNotExists(name.init :+ newName, table.schema)
+      case AlterTableRenameColumn(table: ResolvedTable, col: 
ResolvedFieldName, newName) =>
+        checkColumnNotExists(col.path :+ newName, table.schema)
+      case a @ AlterTableAlterColumn(table: ResolvedTable, col: 
ResolvedFieldName, _, _, _, _) =>
+        val fieldName = col.name.quoted
+        if (a.dataType.isDefined) {
+          val field = CharVarcharUtils.getRawType(col.field.metadata)
+            .map(dt => col.field.copy(dataType = dt))
+            .getOrElse(col.field)
+          val newDataType = a.dataType.get
+          newDataType match {

Review comment:
       Actually, this is OK. In the analzer, we will set the `newDataType` to 
None if it's the same with the existing data type in the table.




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

Reply via email to