Skip to content

Commit

Permalink
Fix(snowflake): parse CREATE SEQUENCE with commas (#3436)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas committed May 8, 2024
1 parent 30f9d30 commit 273731f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@ def _parse_sequence_properties(self) -> t.Optional[exp.SequenceProperties]:
index = self._index

while self._curr:
self._match(TokenType.COMMA)
if self._match_text_seq("INCREMENT"):
self._match_text_seq("BY")
self._match_text_seq("=")
Expand Down
8 changes: 8 additions & 0 deletions tests/dialects/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,14 @@ def test_ddl(self):
"CREATE OR REPLACE FUNCTION my_udtf(foo BOOLEAN) RETURNS TABLE(col1 ARRAY(INT)) AS $$ WITH t AS (SELECT CAST([1, 2, 3] AS ARRAY(INT)) AS c) SELECT c FROM t $$",
"CREATE OR REPLACE FUNCTION my_udtf(foo BOOLEAN) RETURNS TABLE (col1 ARRAY(INT)) AS ' WITH t AS (SELECT CAST([1, 2, 3] AS ARRAY(INT)) AS c) SELECT c FROM t '",
)
self.validate_identity(
"CREATE SEQUENCE seq1 WITH START=1, INCREMENT=1 ORDER",
"CREATE SEQUENCE seq1 START=1 INCREMENT BY 1 ORDER",
)
self.validate_identity(
"CREATE SEQUENCE seq1 WITH START=1 INCREMENT=1 ORDER",
"CREATE SEQUENCE seq1 START=1 INCREMENT=1 ORDER",
)

self.validate_all(
"CREATE TABLE orders_clone CLONE orders",
Expand Down

0 comments on commit 273731f

Please sign in to comment.