-
Notifications
You must be signed in to change notification settings - Fork 29k
[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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
91c8e58
ALTER TABLE CHANGE COLUMN should do multi-catalog resolution.
viirya a432da7
Merge remote-tracking branch 'upstream/master' into SPARK-29680
viirya 05f0584
Remove ALTER TABLE CHANGE COLUMN syntax.
viirya 17a34c2
Fix test case.
viirya dade338
Merge remote-tracking branch 'upstream/master' into SPARK-29680
viirya fb7564a
Generate new test result.
viirya 9e7a678
Remove unnecessary sql.
viirya ac76822
Merge remote-tracking branch 'upstream/master' into SPARK-29680
viirya 64a68fc
Fix missing test.
viirya b2acddb
qualified column name should be multipartIdentifier.
viirya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
Contributor
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?
Member
Author
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; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
multipartIdentifierYou 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.