Skip to content

Commit

Permalink
[Snowflake]Fix TAG are schema-level object (#3643)
Browse files Browse the repository at this point in the history
* TAG are schema-level object

* use of tag_value
  • Loading branch information
MasterKuat authored Aug 2, 2023
1 parent d4f4c9d commit eba5c44
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
34 changes: 18 additions & 16 deletions sql/snowflake/SnowflakeParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ column_unset_tags
;

alter_tag
: ALTER TAG alter_tag_opts
: ALTER TAG if_exists? object_name alter_tag_opts
;

alter_task
Expand Down Expand Up @@ -1365,13 +1365,13 @@ alter_user_opts
;

alter_tag_opts
: if_exists? id_ RENAME TO id_
| if_exists? id_ ( ADD | DROP ) ALLOWED_VALUES string (COMMA string)*
| id_ UNSET ALLOWED_VALUES
| id_ SET MASKING POLICY id_ (COMMA MASKING POLICY id_)*
| id_ UNSET MASKING POLICY id_ (COMMA MASKING POLICY id_)*
| if_exists? id_ SET comment_clause
| if_exists? id_ UNSET COMMENT
: RENAME TO object_name
| ( ADD | DROP ) tag_allowed_values
| UNSET ALLOWED_VALUES
| SET MASKING POLICY id_ (COMMA MASKING POLICY id_)*
| UNSET MASKING POLICY id_ (COMMA MASKING POLICY id_)*
| SET comment_clause
| UNSET COMMENT
;

alter_network_policy_opts
Expand Down Expand Up @@ -1408,11 +1408,11 @@ set_tags
;

tag_decl_list
: TAG id_ EQ tag_value (COMMA id_ EQ tag_value )*
: TAG object_name EQ tag_value (COMMA object_name EQ tag_value )*
;

unset_tags
: UNSET TAG id_ (COMMA id_)*
: UNSET TAG object_name (COMMA object_name)*
;

// create commands
Expand Down Expand Up @@ -1871,9 +1871,7 @@ create_resource_monitor
;

create_role
: CREATE or_replace? ROLE if_not_exists? id_
( WITH? TAG LR_BRACKET id_ EQ STRING ( COMMA id_ EQ STRING )* RR_BRACKET )?
( COMMENT EQ STRING )?
: CREATE or_replace? ROLE if_not_exists? id_ with_tags? comment_clause?
;

create_row_access_policy
Expand Down Expand Up @@ -2465,7 +2463,11 @@ create_table_like
;

create_tag
: CREATE or_replace? TAG if_not_exists? id_ ( ALLOWED_VALUES string (COMMA string)* )? comment_clause?
: CREATE or_replace? TAG if_not_exists? object_name tag_allowed_values? comment_clause?
;

tag_allowed_values
: ALLOWED_VALUES tag_value (COMMA tag_value)*
;

session_parameter
Expand Down Expand Up @@ -2818,7 +2820,7 @@ drop_table
;

drop_tag
: DROP TAG if_exists? id_
: DROP TAG if_exists? object_name
;

drop_task
Expand Down Expand Up @@ -2867,7 +2869,7 @@ undrop_table
;

undrop_tag
: UNDROP TAG id_
: UNDROP TAG object_name
;

// use commands
Expand Down
1 change: 1 addition & 0 deletions sql/snowflake/examples/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ create warehouse w;
create database public;
create or replace stream str_test2 on table test_str at (STREAM => 'STR_TEST2');
create schema raw;
create tag public.t ALLOWED_VALUES 'V1' comment ='1';

0 comments on commit eba5c44

Please sign in to comment.