You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/05 04:44:42 UTC
[GitHub] [spark] cloud-fan commented on a change in pull request #33113: [SPARK-34302][SQL] Migrate ALTER TABLE ... CHANGE COLUMN command to use UnresolvedTable to resolve the identifier
cloud-fan commented on a change in pull request #33113:
URL: https://github.com/apache/spark/pull/33113#discussion_r663634209
##########
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:
Not related to this PR: I think there is a small bug here, if the data type is not changed, we shouldn't fail even if the new data type is struct/array/map. @imback82 can you help to fix it?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org