Skip to content

Commit

Permalink
fix(tsql): transpile snowflake TIMESTAMP_NTZ to DATETIME2 (#4576)
Browse files Browse the repository at this point in the history
* fix(tsql): transpile snowflake TIMESTAMP_NTZ to DATETIME2

* PR feedback 1

Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>

* PR feedback 1 (fix style)

---------

Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
  • Loading branch information
geooo109 and georgesittas authored Jan 8, 2025
1 parent 9921528 commit 139b699
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/dialects/tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ class Generator(generator.Generator):
exp.DataType.Type.ROWVERSION: "ROWVERSION",
exp.DataType.Type.TEXT: "VARCHAR(MAX)",
exp.DataType.Type.TIMESTAMP: "DATETIME2",
exp.DataType.Type.TIMESTAMPNTZ: "DATETIME2",
exp.DataType.Type.TIMESTAMPTZ: "DATETIMEOFFSET",
exp.DataType.Type.SMALLDATETIME: "SMALLDATETIME",
exp.DataType.Type.UTINYINT: "TINYINT",
Expand Down
10 changes: 10 additions & 0 deletions tests/dialects/test_tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,16 @@ def test_types_date(self):
},
)

self.validate_all(
"CREATE TABLE t (col1 DATETIME2(2))",
read={
"snowflake": "CREATE TABLE t (col1 TIMESTAMP_NTZ(2))",
},
write={
"tsql": "CREATE TABLE t (col1 DATETIME2(2))",
},
)

def test_types_bin(self):
self.validate_all(
"CAST(x as BIT)",
Expand Down

0 comments on commit 139b699

Please sign in to comment.