Repository: tobymao/sqlglot

Issue:
Allow comma-separated values for `CREATE SEQUENCE` properties (Snowflake)
Allow comma-separated values for `CREATE SEQUENCE` properties in Snowflake queries.

This query can be parsed successfully (results is an instance of `exp.Create`):
```
    query = "CREATE SEQUENCE seq1 WITH START=1 INCREMENT=1 ORDER"
    result = parse_one(query, dialect="snowflake")
    print(type(result))

    --> <class 'sqlglot.expressions.Create'>
```

... whereas the following query cannot be fully parsed and is returned as a generic `exp.Command` as fallback:
```
    query = "CREATE SEQUENCE seq1 WITH START=1, INCREMENT=1 ORDER"
    result = parse_one(query, dialect="snowflake")
    print(type(result))

    --> <class 'sqlglot.expressions.Command'>
```

(note - the only subtle difference is the comma `,` between the `START` and `INCREMENT` properties)

Note that the second query syntax may not be covered in the Snowflake docs, but it is indeed a valid syntax that can be executed against Snowflake (and some Snowflake client apps/SDKs are generating queries that are using this syntax, unfortunately).

Discussion:

Patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 229af18a..8f5050ee 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -1678,6 +1678,7 @@ class Parser(metaclass=_Parser):
         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("=")


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index d03412ca..c9150ff3 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -1223,6 +1223,14 @@ WHERE
             "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",