Skip to content

Commit

Permalink
fix(snowflake): support correct AUTO INCREMENT transpilation (#4696)
Browse files Browse the repository at this point in the history
  • Loading branch information
geooo109 authored Feb 3, 2025
1 parent 1904b76 commit a688b6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sqlglot/dialects/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,10 @@ class Generator(generator.Generator):
exp.DataType.Type.STRUCT: "OBJECT",
}

TOKEN_MAPPING = {
TokenType.AUTO_INCREMENT: "AUTOINCREMENT",
}

PROPERTIES_LOCATION = {
**generator.Generator.PROPERTIES_LOCATION,
exp.SetProperty: exp.Properties.Location.UNSUPPORTED,
Expand Down
2 changes: 2 additions & 0 deletions tests/dialects/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,8 @@ def test_snowflake(self):
self.validate_identity("SELECT BIT_SHIFTLEFT(a, 1)", "SELECT BITSHIFTLEFT(a, 1)")
self.validate_identity("SELECT BIT_SHIFTRIGHT(a, 1)", "SELECT BITSHIFTRIGHT(a, 1)")

self.validate_identity("CREATE TABLE t (id INT PRIMARY KEY AUTOINCREMENT)")

def test_null_treatment(self):
self.validate_all(
r"SELECT FIRST_VALUE(TABLE1.COLUMN1) OVER (PARTITION BY RANDOM_COLUMN1, RANDOM_COLUMN2 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS MY_ALIAS FROM TABLE1",
Expand Down

0 comments on commit a688b6c

Please sign in to comment.