Github user xuanyuanking commented on a diff in the pull request:
https://github.com/apache/spark/pull/19773#discussion_r204805474
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
@@ -318,18 +318,34 @@ case class AlterTableChangeColumnCommand(
// Find the origin column from dataSchema by column name.
val originColumn = findColumnByName(table.dataSchema, columnName,
resolver)
- // Throw an AnalysisException if the column name/dataType is changed.
+ // Throw an AnalysisException if the column name is changed.
if (!columnEqual(originColumn, newColumn, resolver)) {
throw new AnalysisException(
"ALTER TABLE CHANGE COLUMN is not supported for changing column " +
s"'${originColumn.name}' with type '${originColumn.dataType}' to
" +
s"'${newColumn.name}' with type '${newColumn.dataType}'")
}
+ val typeChanged = originColumn.dataType != newColumn.dataType
+ val partitionColumnChanged =
table.partitionColumnNames.contains(originColumn.name)
+
+ // Throw an AnalysisException if the type of partition column is
changed.
+ if (typeChanged && partitionColumnChanged) {
--- End diff --
Just adding a check here when user changing the type of partition columns.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]