-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -51,7 +51,6 @@ | |
r"rows", | ||
r"support", | ||
r"set", | ||
r"as", | ||
# snowflake | ||
r"comment", | ||
r"imports", | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from functools import partial | ||
|
||
from sqlfmt import actions | ||
from sqlfmt.rule import Rule | ||
from sqlfmt.rules.common import ALTER_WAREHOUSE, CREATE_WAREHOUSE, group | ||
from sqlfmt.rules.core import CORE | ||
from sqlfmt.token import TokenType | ||
|
||
WAREHOUSE = [ | ||
*CORE, | ||
Rule( | ||
name="unterm_keyword", | ||
priority=1300, | ||
pattern=group( | ||
CREATE_WAREHOUSE, | ||
ALTER_WAREHOUSE, | ||
# objectProperties | ||
r"(with\s+|(un)?set\s+)?" | ||
+ group( | ||
r"warehouse_type", | ||
r"warehouse_size", | ||
r"max_cluster_count", | ||
r"min_cluster_count", | ||
r"scaling_policy", | ||
r"auto_suspend", | ||
r"auto_resume", | ||
r"initially_suspended", | ||
r"resource_monitor", | ||
r"comment", | ||
r"enable_query_acceleration", | ||
r"query_acceleration_max_scale_factor", | ||
r"tag", | ||
), | ||
# objectParams | ||
r"(set\s+)?" | ||
+ group( | ||
r"max_concurrency_level", | ||
r"statement_queued_timeout_in_seconds", | ||
r"statement_timeout_in_seconds", | ||
), | ||
# alter | ||
r"suspend", | ||
r"resume(\s+if\s+suspended)?", | ||
r"abort\s+all\s+queries", | ||
r"rename\s+to", | ||
) | ||
+ group(r"\W", r"$"), | ||
action=partial(actions.add_node_to_buffer, token_type=TokenType.UNTERM_KEYWORD), | ||
), | ||
] |
This file contains 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
create or replace warehouse foo | ||
warehouse_size='XLARGE' | ||
warehouse_type='SNOWPARK-OPTIMIZED' | ||
max_cluster_count=6; | ||
create | ||
warehouse if not exists foo | ||
with warehouse_size = 'X5LARGE' | ||
AUTO_SUSPEND = 100 | ||
AUTO_RESUME = FALSE | ||
INITIALLY_SUSPENDED = TRUE; | ||
|
||
alter warehouse if exists foo set warehouse_size='XSMALL'; alter warehouse if exists foo set tag 'foobar'='baz', 'another_really_long_tag_name'='really_very_long_tag_value_quxxxxxxxxxxxxxxxxxxx', 'bar'='baz'; | ||
|
||
alter warehouse foo rename to bar; | ||
alter warehouse bar resume if suspended; | ||
)))))__SQLFMT_OUTPUT__((((( | ||
create or replace warehouse foo | ||
warehouse_size = 'XLARGE' | ||
warehouse_type = 'SNOWPARK-OPTIMIZED' | ||
max_cluster_count = 6 | ||
; | ||
create warehouse if not exists foo | ||
with warehouse_size = 'X5LARGE' | ||
auto_suspend = 100 | ||
auto_resume = false | ||
initially_suspended = true | ||
; | ||
|
||
alter warehouse if exists foo | ||
set warehouse_size = 'XSMALL' | ||
; | ||
alter warehouse if exists foo | ||
set tag | ||
'foobar' = 'baz', | ||
'another_really_long_tag_name' = 'really_very_long_tag_value_quxxxxxxxxxxxxxxxxxxx', | ||
'bar' = 'baz' | ||
; | ||
|
||
alter warehouse foo | ||
rename to bar | ||
; | ||
alter warehouse bar | ||
resume if suspended | ||
; |
This file contains 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 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