[HUDI-3237] gracefully fail to change column data type (#4677)
This commit is contained in:
@@ -239,10 +239,6 @@ alter table h2_p add columns(ext0 int);
|
||||
+----------+
|
||||
| ok |
|
||||
+----------+
|
||||
alter table h2_p change column ext0 ext0 bigint;
|
||||
+----------+
|
||||
| ok |
|
||||
+----------+
|
||||
|
||||
# DROP TABLE
|
||||
drop table h0;
|
||||
|
||||
@@ -91,9 +91,10 @@ class TestAlterTable extends TestHoodieSqlBase {
|
||||
)
|
||||
|
||||
// change column's data type
|
||||
spark.sql(s"alter table $newTableName change column id id bigint")
|
||||
assertResult(StructType(Seq(StructField("id", LongType, nullable = true))))(
|
||||
spark.sql(s"select id from $newTableName").schema)
|
||||
checkExceptionContain(s"alter table $newTableName change column id id bigint") (
|
||||
"ALTER TABLE CHANGE COLUMN is not supported for changing column 'id'" +
|
||||
" with type 'IntegerType' to 'id' with type 'LongType'"
|
||||
)
|
||||
|
||||
// Insert data to the new table.
|
||||
spark.sql(s"insert into $newTableName values(2, 'a2', 12, 1000, 'e0')")
|
||||
|
||||
Reference in New Issue
Block a user