-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-29680][SQL] Remove ALTER TABLE CHANGE COLUMN syntax #26338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
91c8e58
a432da7
05f0584
17a34c2
dade338
fb7564a
9e7a678
ac76822
64a68fc
b2acddb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,11 +149,8 @@ statement | |
| ALTER (TABLE | VIEW) multipartIdentifier | ||
UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ||
| ALTER TABLE multipartIdentifier | ||
(ALTER | CHANGE) COLUMN? qualifiedName | ||
(ALTER | CHANGE) COLUMN? multipartIdentifier | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we use This conflicts a test in ErrorParserSuite that The column name should be multiple errorCapturingIdentifier. So I changed it to multipartIdentifier:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like we should replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. will make a followup later. |
||
(TYPE dataType)? (COMMENT comment=STRING)? colPosition? #alterTableColumn | ||
| ALTER TABLE tableIdentifier partitionSpec? | ||
CHANGE COLUMN? | ||
colName=errorCapturingIdentifier colType colPosition? #changeColumn | ||
| ALTER TABLE multipartIdentifier (partitionSpec)? | ||
SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ||
| ALTER TABLE multipartIdentifier (partitionSpec)? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,56 +2,43 @@ | |
CREATE TABLE test_change(a INT, b STRING, c INT) using parquet; | ||
DESC test_change; | ||
|
||
-- Change column name (not supported yet) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a test file for RENAME COLUMN? If not can we add some tests here to keep the test coverage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
ALTER TABLE test_change CHANGE a a1 INT; | ||
-- ALTER TABLE CHANGE COLUMN must change either type or comment | ||
ALTER TABLE test_change CHANGE a; | ||
DESC test_change; | ||
|
||
-- Change column name (not supported on v1 table) | ||
ALTER TABLE test_change RENAME COLUMN a TO a1; | ||
DESC test_change; | ||
|
||
-- Change column dataType (not supported yet) | ||
ALTER TABLE test_change CHANGE a a STRING; | ||
ALTER TABLE test_change CHANGE a TYPE STRING; | ||
DESC test_change; | ||
|
||
-- Change column position (not supported yet) | ||
ALTER TABLE test_change CHANGE a a INT AFTER b; | ||
ALTER TABLE test_change CHANGE b b STRING FIRST; | ||
ALTER TABLE test_change CHANGE a TYPE INT AFTER b; | ||
ALTER TABLE test_change CHANGE b TYPE STRING FIRST; | ||
DESC test_change; | ||
|
||
-- Change column comment | ||
ALTER TABLE test_change CHANGE a a INT COMMENT 'this is column a'; | ||
ALTER TABLE test_change CHANGE b b STRING COMMENT '#*02?`'; | ||
ALTER TABLE test_change CHANGE c c INT COMMENT ''; | ||
ALTER TABLE test_change CHANGE a TYPE INT COMMENT 'this is column a'; | ||
ALTER TABLE test_change CHANGE b TYPE STRING COMMENT '#*02?`'; | ||
ALTER TABLE test_change CHANGE c TYPE INT COMMENT ''; | ||
DESC test_change; | ||
|
||
-- Don't change anything. | ||
ALTER TABLE test_change CHANGE a a INT COMMENT 'this is column a'; | ||
ALTER TABLE test_change CHANGE a TYPE INT COMMENT 'this is column a'; | ||
DESC test_change; | ||
|
||
-- Change a invalid column | ||
ALTER TABLE test_change CHANGE invalid_col invalid_col INT; | ||
DESC test_change; | ||
|
||
-- Change column name/dataType/position/comment together (not supported yet) | ||
ALTER TABLE test_change CHANGE a a1 STRING COMMENT 'this is column a1' AFTER b; | ||
DESC test_change; | ||
|
||
-- Check the behavior with different values of CASE_SENSITIVE | ||
SET spark.sql.caseSensitive=false; | ||
ALTER TABLE test_change CHANGE a A INT COMMENT 'this is column A'; | ||
SET spark.sql.caseSensitive=true; | ||
ALTER TABLE test_change CHANGE a A INT COMMENT 'this is column A1'; | ||
ALTER TABLE test_change CHANGE invalid_col TYPE INT; | ||
DESC test_change; | ||
|
||
-- Change column can't apply to a temporary/global_temporary view | ||
CREATE TEMPORARY VIEW temp_view(a, b) AS SELECT 1, "one"; | ||
ALTER TABLE temp_view CHANGE a a INT COMMENT 'this is column a'; | ||
ALTER TABLE temp_view CHANGE a TYPE INT COMMENT 'this is column a'; | ||
CREATE GLOBAL TEMPORARY VIEW global_temp_view(a, b) AS SELECT 1, "one"; | ||
ALTER TABLE global_temp.global_temp_view CHANGE a a INT COMMENT 'this is column a'; | ||
|
||
-- Change column in partition spec (not supported yet) | ||
CREATE TABLE partition_table(a INT, b STRING, c INT, d STRING) USING parquet PARTITIONED BY (c, d); | ||
ALTER TABLE partition_table PARTITION (c = 1) CHANGE COLUMN a new_a INT; | ||
ALTER TABLE partition_table CHANGE COLUMN c c INT COMMENT 'this is column C'; | ||
ALTER TABLE global_temp.global_temp_view CHANGE a TYPE INT COMMENT 'this is column a'; | ||
|
||
-- DROP TEST TABLE | ||
DROP TABLE test_change; | ||
DROP TABLE partition_table; | ||
DROP VIEW global_temp.global_temp_view; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can distinguish the two
multipartIdentifier
You can fix it in your followup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.