Skip to content

Commit

Permalink
Support Snowflake column rename (#2327)
Browse files Browse the repository at this point in the history
  • Loading branch information
wong-codaio committed Jan 17, 2022
1 parent 0ea874b commit 145f490
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/sqlfluff/dialects/dialect_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,14 @@ class AlterTableTableColumnActionSegment(BaseSegment):
match_grammar = Sequence(
OneOf(
# @TODO: Add Column
# @TODO: Rename column
# Rename column
Sequence(
"RENAME",
"COLUMN",
Ref("ColumnReferenceSegment"),
"TO",
Ref("ColumnReferenceSegment"),
),
# Alter/Modify column(s)
Sequence(
OneOf("ALTER", "MODIFY"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ alter table empl_info modify
-- DROP COLUMN
ALTER TABLE empl_info DROP COLUMN my_column;
ALTER TABLE some_schema.empl_info DROP COLUMN my_column;


-- Rename column
ALTER TABLE empl_info RENAME COLUMN old_col_name TO new_col_name;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: ceacb0017f29185609aade7a85afc1b23121f52bd2080202295cdb5d58d83cd0
_hash: 4db9f464f87c27464350e4314b93708eeda0b3c5b6d44a95cd0984edd9b01dbb
file:
- statement:
alter_table_statement:
Expand Down Expand Up @@ -202,3 +202,18 @@ file:
- column_reference:
identifier: my_column
- statement_terminator: ;
- statement:
alter_table_statement:
- keyword: ALTER
- keyword: TABLE
- table_reference:
identifier: empl_info
- alter_table_table_column_action:
- keyword: RENAME
- keyword: COLUMN
- column_reference:
identifier: old_col_name
- keyword: TO
- column_reference:
identifier: new_col_name
- statement_terminator: ;

0 comments on commit 145f490

Please sign in to comment.