Github user xuanyuanking commented on a diff in the pull request:
https://github.com/apache/spark/pull/19773#discussion_r215859851
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
---
@@ -1697,6 +1697,16 @@ abstract class DDLSuite extends QueryTest with
SQLTestUtils {
sql("ALTER TABLE dbx.tab1 CHANGE COLUMN col1 col1 INT COMMENT 'this is
col1'")
assert(getMetadata("col1").getString("key") == "value")
assert(getMetadata("col1").getString("comment") == "this is col1")
+
+ // Ensure that changing column type takes effect
+ sql("ALTER TABLE dbx.tab1 CHANGE COLUMN col1 col1 STRING")
+ val column =
catalog.getTableMetadata(tableIdent).schema.fields.find(_.name == "col1")
+ assert(column.get.dataType == StringType)
+
+ // Ensure that changing partition column type throw exception
+ intercept[AnalysisException] {
+ sql("ALTER TABLE dbx.tab1 CHANGE COLUMN a a STRING")
+ }
--- End diff --
Thanks, done in ef65c4d. Also add check for type compatible check.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]