Skip to content

Commit bee4cab

Browse files
authored
snowflake - warehouse new features (#3788)
* sf wh new features * non reserved keywords * review
1 parent 09c7b27 commit bee4cab

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

sql/snowflake/SnowflakeLexer.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ SNAPPY: 'SNAPPY';
835835
SNAPPY_COMPRESSION: 'SNAPPY_COMPRESSION';
836836
SNOWFLAKE_FULL: 'SNOWFLAKE_FULL';
837837
SNOWFLAKE_SSE: 'SNOWFLAKE_SSE';
838+
SNOWPARK_OPTIMIZED: '\'SNOWPARK-OPTIMIZED\'';
838839
SOME: 'SOME';
839840
// SOUNDEX: 'SOUNDEX';
840841
SOURCE: 'SOURCE';
@@ -1036,6 +1037,7 @@ VOLATILE: 'VOLATILE';
10361037
WAREHOUSE: 'WAREHOUSE';
10371038
WAREHOUSES: 'WAREHOUSES';
10381039
WAREHOUSE_SIZE: 'WAREHOUSE_SIZE';
1040+
WAREHOUSE_TYPE: 'WAREHOUSE_TYPE';
10391041
WEEKLY: 'WEEKLY';
10401042
WEEK_OF_YEAR_POLICY: 'WEEK_OF_YEAR_POLICY';
10411043
WEEK_START: 'WEEK_START';

sql/snowflake/SnowflakeParser.g4

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ alter_tag
12821282

12831283
alter_task
12841284
: ALTER TASK if_exists? object_name resume_suspend
1285-
| ALTER TASK if_exists? object_name ( REMOVE | ADD ) AFTER string_list
1285+
| ALTER TASK if_exists? object_name ( REMOVE | ADD ) AFTER string_list
12861286
| ALTER TASK if_exists? object_name SET
12871287
// TODO : Check and review if element's order binded or not
12881288
( WAREHOUSE EQ id_ )?
@@ -1386,6 +1386,7 @@ alter_warehouse_opts
13861386
| id_fn set_tags
13871387
| id_fn unset_tags
13881388
| id_fn UNSET id_ (COMMA id_)*
1389+
| id_ SET wh_properties (',' wh_properties)*
13891390
;
13901391

13911392
alter_account_opts
@@ -2013,6 +2014,27 @@ create_share
20132014

20142015
character
20152016
: CHAR_LITERAL
2017+
| AAD_PROVISIONER_Q
2018+
| ARRAY_Q
2019+
| AUTO_Q
2020+
| AVRO_Q
2021+
| AZURE_CSE_Q
2022+
| AZURE_Q
2023+
| BOTH_Q
2024+
| CSV_Q
2025+
| GCS_SSE_KMS_Q
2026+
| GENERIC_Q
2027+
| GENERIC_SCIM_PROVISIONER_Q
2028+
| JSON_Q
2029+
| NONE_Q
2030+
| OBJECT_Q
2031+
| OKTA_PROVISIONER_Q
2032+
| OKTA_Q
2033+
| ORC_Q
2034+
| PARQUET_Q
2035+
| S3
2036+
| SNOWPARK_OPTIMIZED
2037+
| XML_Q
20162038
;
20172039

20182040
format_type_options
@@ -2583,7 +2605,7 @@ task_parameters
25832605

25842606
task_compute
25852607
: WAREHOUSE EQ id_
2586-
| USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE EQ ( wh_common_size | string ) //Snowflake allow quoted warehouse size but must be without quote.
2608+
| USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE EQ ( wh_common_size | string ) //Snowflake allow quoted warehouse size but must be without quote.
25872609
;
25882610

25892611
task_schedule
@@ -2599,7 +2621,7 @@ task_suspend_after_failure_number
25992621
;
26002622

26012623
task_error_integration
2602-
: ERROR_INTEGRATION EQ id_
2624+
: ERROR_INTEGRATION EQ id_
26032625
;
26042626

26052627
task_overlap
@@ -2657,6 +2679,7 @@ wh_extra_size
26572679

26582680
wh_properties
26592681
: WAREHOUSE_SIZE EQ ( wh_common_size | wh_extra_size | ID2)
2682+
| WAREHOUSE_TYPE EQ (STANDARD | SNOWPARK_OPTIMIZED)
26602683
| MAX_CLUSTER_COUNT EQ num
26612684
| MIN_CLUSTER_COUNT EQ num
26622685
| SCALING_POLICY EQ (STANDARD | ECONOMY)
@@ -2667,6 +2690,7 @@ wh_properties
26672690
| comment_clause
26682691
| ENABLE_QUERY_ACCELERATION EQ true_false
26692692
| QUERY_ACCELERATION_MAX_SCALE_FACTOR EQ num
2693+
| MAX_CONCURRENCY_LEVEL EQ num
26702694
;
26712695

26722696
wh_params
@@ -3592,6 +3616,8 @@ non_reserved_words
35923616
| DYNAMIC
35933617
| TARGET_LAG
35943618
| EMAIL
3619+
| MAX_CONCURRENCY_LEVEL
3620+
| WAREHOUSE_TYPE
35953621
;
35963622

35973623
builtin_function

sql/snowflake/examples/ids.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ create table alert(i int);
22
create table alerts(i int);
33
create table condition(i int);
44
create table dt_t(dynamic int, downstream int, target_lag int);
5+
create table wh_id(MAX_CONCURRENCY_LEVEL int, WAREHOUSE_TYPE int);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CREATE WAREHOUSE IF NOT EXISTS wh1
2+
WAREHOUSE_SIZE = MEDIUM
3+
WAREHOUSE_TYPE = 'SNOWPARK-OPTIMIZED'
4+
MAX_CLUSTER_COUNT = 2
5+
MIN_CLUSTER_COUNT = 1
6+
SCALING_POLICY = ECONOMY
7+
AUTO_SUSPEND = 15
8+
AUTO_RESUME = TRUE
9+
INITIALLY_SUSPENDED = TRUE
10+
COMMENT = 'text'
11+
ENABLE_QUERY_ACCELERATION = TRUE
12+
QUERY_ACCELERATION_MAX_SCALE_FACTOR = 1
13+
STATEMENT_TIMEOUT_IN_SECONDS = 10
14+
;
15+
16+
CREATE WAREHOUSE IF NOT EXISTS wh2
17+
WAREHOUSE_SIZE = SMALL
18+
WAREHOUSE_TYPE = STANDARD
19+
MAX_CLUSTER_COUNT = 2
20+
MIN_CLUSTER_COUNT = 1
21+
SCALING_POLICY = ECONOMY
22+
AUTO_SUSPEND = 15
23+
AUTO_RESUME = TRUE
24+
INITIALLY_SUSPENDED = TRUE
25+
COMMENT = 'text'
26+
ENABLE_QUERY_ACCELERATION = TRUE
27+
QUERY_ACCELERATION_MAX_SCALE_FACTOR = 1
28+
STATEMENT_TIMEOUT_IN_SECONDS = 10
29+
;
30+
31+
ALTER WAREHOUSE IF EXISTS wh1 SET MAX_CONCURRENCY_LEVEL = 8;
32+
33+
ALTER WAREHOUSE IF EXISTS wh2 SET WAREHOUSE_SIZE = MEDIUM, WAREHOUSE_TYPE = 'SNOWPARK-OPTIMIZED';

0 commit comments

Comments
 (0)