Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into TSQL_TRY_CATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
jpersons committed Dec 6, 2021
2 parents 5703514 + 42b142e commit 031aa9b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 67 deletions.
89 changes: 43 additions & 46 deletions src/sqlfluff/dialects/dialect_snowflake.py
Expand Up @@ -112,11 +112,12 @@
),
# We use a RegexParser instead of keywords as some (those with dashes) require quotes:
WarehouseSize=RegexParser(
r"(XSMALL|SMALL|MEDIUM|LARGE|XLARGE|XXLARGE|X2LARGE|XXXLARGE|X3LARGE|X4LARGE|X5LARGE|X6LARGE|"
r"('?XSMALL'?|'?SMALL'?|'?MEDIUM'?|'?LARGE'?|'?XLARGE'?|'?XXLARGE'?|'?X2LARGE'?|"
r"'?XXXLARGE'?|'?X3LARGE'?|'?X4LARGE'?|'?X5LARGE|'?X6LARGE'?|"
r"'X-SMALL'|'X-LARGE'|'2X-LARGE'|'3X-LARGE'|'4X-LARGE'|'5X-LARGE'|'6X-LARGE')",
CodeSegment,
name="warehouse_size",
type="identifier",
type="warehouse_size",
),
DoubleQuotedLiteralSegment=NamedParser(
"double_quote",
Expand Down Expand Up @@ -1653,55 +1654,51 @@ class CreateTaskSegment(BaseSegment):
Sequence("IF", "NOT", "EXISTS", optional=True),
Ref("ObjectReferenceSegment"),
Indent,
Sequence(
"WAREHOUSE",
Ref("EqualsSegment"),
Ref("ObjectReferenceSegment"),
optional=True,
),
Sequence(
"SCHEDULE",
Ref("EqualsSegment"),
Ref("QuotedLiteralSegment"),
optional=True,
),
Sequence(
"ALLOW_OVERLAPPING_EXECUTION",
Ref("EqualsSegment"),
Ref("BooleanLiteralGrammar"),
optional=True,
),
Delimited(
AnyNumberOf(
OneOf(
Sequence(
"WAREHOUSE",
Ref("EqualsSegment"),
Ref("ObjectReferenceSegment"),
),
Sequence(
"USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE",
Ref("EqualsSegment"),
Ref("WarehouseSize"),
),
),
Sequence(
Ref("ParameterNameSegment"),
"SCHEDULE",
Ref("EqualsSegment"),
OneOf(
Ref("BooleanLiteralGrammar"),
Ref("QuotedLiteralSegment"),
Ref("NumericLiteralSegment"),
Ref("QuotedLiteralSegment"),
),
Sequence(
"ALLOW_OVERLAPPING_EXECUTION",
Ref("EqualsSegment"),
Ref("BooleanLiteralGrammar"),
),
Delimited(
Sequence(
Ref("ParameterNameSegment"),
Ref("EqualsSegment"),
OneOf(
Ref("BooleanLiteralGrammar"),
Ref("QuotedLiteralSegment"),
Ref("NumericLiteralSegment"),
),
),
),
delimiter=Ref("CommaSegment"),
optional=True,
),
Sequence(
"USER_TASK_TIMEOUT_MS",
Ref("EqualsSegment"),
Ref("NumericLiteralSegment"),
optional=True,
),
Sequence(
"USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE",
Ref("EqualsSegment"),
Ref("QuotedLiteralSegment"),
optional=True,
),
Sequence(
"COPY",
"GRANTS",
optional=True,
Sequence(
"USER_TASK_TIMEOUT_MS",
Ref("EqualsSegment"),
Ref("NumericLiteralSegment"),
),
Sequence(
"COPY",
"GRANTS",
),
Ref("CreateStatementCommentSegment"),
),
Ref("CreateStatementCommentSegment", optional=True),
Sequence(
"AFTER",
Ref("ObjectReferenceSegment"),
Expand Down
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: 3e2b9618e0f631b6ae5ebee794c1be3ec49ba8ddf6f71d91d87a7f7030c5de3b
_hash: cafd424f48bcaf1e2cc5194c0d6f1d734cc60cb01fd0ff87bbeae52f3898ba48
file:
- statement:
alter_warehouse_statement:
Expand All @@ -25,7 +25,7 @@ file:
- warehouse_object_properties:
keyword: warehouse_size
comparison_operator: '='
identifier: medium
warehouse_size: medium
- statement_terminator: ;
- statement:
alter_warehouse_statement:
Expand All @@ -36,7 +36,7 @@ file:
- warehouse_object_properties:
keyword: warehouse_size
comparison_operator: '='
identifier: XXLARGE
warehouse_size: XXLARGE
- statement_terminator: ;
- statement:
alter_warehouse_statement:
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/dialects/snowflake/snowflake_create_task.sql
Expand Up @@ -16,7 +16,6 @@ AS

-- All possible optional clauses
CREATE OR REPLACE TASK IF NOT EXISTS t1
WAREHOUSE = mywh
SCHEDULE = 'USING CRON 0 9-17 * * SUN America/Los_Angeles'
ALLOW_OVERLAPPING_EXECUTION = TRUE
TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
Expand Down
19 changes: 7 additions & 12 deletions test/fixtures/dialects/snowflake/snowflake_create_task.yml
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: 30f5f73cf11d4e4c4483381ee36a2c8dd448e80932b59d6d468e9286882f755f
_hash: 3268f1a30f1f80b907141692283aa593ed92af99a112c8de24b4d3c27ff09c09
file:
- statement:
create_task_statement:
Expand All @@ -19,7 +19,7 @@ file:
- literal: "'YYYY-MM-DD HH24'"
- keyword: USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE
- comparison_operator: '='
- literal: "'XSMALL'"
- warehouse_size: "'XSMALL'"
- keyword: AS
- statement:
insert_statement:
Expand Down Expand Up @@ -89,10 +89,6 @@ file:
- keyword: EXISTS
- object_reference:
identifier: t1
- keyword: WAREHOUSE
- comparison_operator: '='
- object_reference:
identifier: mywh
- keyword: SCHEDULE
- comparison_operator: '='
- literal: "'USING CRON 0 9-17 * * SUN America/Los_Angeles'"
Expand All @@ -102,18 +98,17 @@ file:
- parameter: TIMESTAMP_INPUT_FORMAT
- comparison_operator: '='
- literal: "'YYYY-MM-DD HH24'"
- keyword: USER_TASK_TIMEOUT_MS
- parameter: USER_TASK_TIMEOUT_MS
- comparison_operator: '='
- literal: '25'
- keyword: USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE
- comparison_operator: '='
- literal: "'XSMALL'"
- warehouse_size: "'XSMALL'"
- keyword: COPY
- keyword: GRANTS
- snowflake_comment:
keyword: COMMENT
comparison_operator: '='
literal: "'Hello world'"
- parameter: COMMENT
- comparison_operator: '='
- literal: "'Hello world'"
- keyword: AFTER
- object_reference:
identifier: dependency_task
Expand Down
@@ -1,3 +1,3 @@
create or replace warehouse my_wh with warehouse_size='X-LARGE';
create or replace warehouse my_wh warehouse_size=large initially_suspended=true;
create warehouse if not exists LOAD_WH warehouse_size=medium;
create warehouse if not exists LOAD_WH warehouse_size='medium';
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: 5981c6fef1dcb2c1ddc5e40118b9aa4eca3d6ff82888dd3e3f67a14be844ac99
_hash: f51e9cb200d28ed6366cea66893600cc6d53313964df3d771e9bb9cfb6193e88
file:
- statement:
create_statement:
Expand All @@ -17,7 +17,7 @@ file:
- warehouse_object_properties:
keyword: warehouse_size
comparison_operator: '='
identifier: "'X-LARGE'"
warehouse_size: "'X-LARGE'"
- statement_terminator: ;
- statement:
create_statement:
Expand All @@ -30,7 +30,7 @@ file:
- warehouse_object_properties:
- keyword: warehouse_size
- comparison_operator: '='
- identifier: large
- warehouse_size: large
- keyword: initially_suspended
- comparison_operator: '='
- literal: 'true'
Expand All @@ -47,5 +47,5 @@ file:
- warehouse_object_properties:
keyword: warehouse_size
comparison_operator: '='
identifier: medium
warehouse_size: "'medium'"
- statement_terminator: ;

0 comments on commit 031aa9b

Please sign in to comment.