diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-04 12:14:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-04 12:14:40 +0000 |
commit | d7f0758e21b5111b5327f3839c5c9f49a04d272b (patch) | |
tree | a425f4ebcc159d6bd9443fe4e0e2f9eb20151027 /tests/dialects/test_tsql.py | |
parent | Adding upstream version 18.7.0. (diff) | |
download | sqlglot-d7f0758e21b5111b5327f3839c5c9f49a04d272b.tar.xz sqlglot-d7f0758e21b5111b5327f3839c5c9f49a04d272b.zip |
Adding upstream version 18.11.2.upstream/18.11.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_tsql.py')
-rw-r--r-- | tests/dialects/test_tsql.py | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/tests/dialects/test_tsql.py b/tests/dialects/test_tsql.py index f76894d..7d89d06 100644 --- a/tests/dialects/test_tsql.py +++ b/tests/dialects/test_tsql.py @@ -7,6 +7,45 @@ class TestTSQL(Validator): def test_tsql(self): self.validate_all( + "CREATE TABLE #mytemptable (a INTEGER)", + read={ + "duckdb": "CREATE TEMPORARY TABLE mytemptable (a INT)", + }, + write={ + "tsql": "CREATE TABLE #mytemptable (a INTEGER)", + "snowflake": "CREATE TEMPORARY TABLE mytemptable (a INT)", + "duckdb": "CREATE TEMPORARY TABLE mytemptable (a INT)", + "oracle": "CREATE TEMPORARY TABLE mytemptable (a NUMBER)", + "hive": "CREATE TEMPORARY TABLE mytemptable (a INT)", + "spark2": "CREATE TEMPORARY TABLE mytemptable (a INT) USING PARQUET", + "spark": "CREATE TEMPORARY TABLE mytemptable (a INT) USING PARQUET", + "databricks": "CREATE TEMPORARY TABLE mytemptable (a INT) USING PARQUET", + }, + ) + self.validate_all( + "CREATE TABLE #mytemp (a INTEGER, b CHAR(2), c TIME(4), d FLOAT(24))", + write={ + "spark": "CREATE TEMPORARY TABLE mytemp (a INT, b CHAR(2), c TIMESTAMP, d FLOAT) USING PARQUET", + "tsql": "CREATE TABLE #mytemp (a INTEGER, b CHAR(2), c TIME(4), d FLOAT(24))", + }, + ) + self.validate_all( + """CREATE TABLE [dbo].[mytable]( + [email] [varchar](255) NOT NULL, + CONSTRAINT [UN_t_mytable] UNIQUE NONCLUSTERED + ( + [email] ASC + ) + )""", + write={ + "hive": "CREATE TABLE `dbo`.`mytable` (`email` VARCHAR(255) NOT NULL)", + "spark2": "CREATE TABLE `dbo`.`mytable` (`email` VARCHAR(255) NOT NULL)", + "spark": "CREATE TABLE `dbo`.`mytable` (`email` VARCHAR(255) NOT NULL)", + "databricks": "CREATE TABLE `dbo`.`mytable` (`email` VARCHAR(255) NOT NULL)", + }, + ) + + self.validate_all( "CREATE TABLE x ( A INTEGER NOT NULL, B INTEGER NULL )", write={ "tsql": "CREATE TABLE x (A INTEGER NOT NULL, B INTEGER NULL)", @@ -492,6 +531,10 @@ class TestTSQL(Validator): ) def test_ddl(self): + self.validate_identity( + "CREATE PROCEDURE foo AS BEGIN DELETE FROM bla WHERE foo < CURRENT_TIMESTAMP - 7 END", + "CREATE PROCEDURE foo AS BEGIN DELETE FROM bla WHERE foo < GETDATE() - 7 END", + ) self.validate_all( "CREATE TABLE tbl (id INTEGER IDENTITY PRIMARY KEY)", read={ @@ -505,6 +548,9 @@ class TestTSQL(Validator): "postgres": "CREATE TABLE tbl (id INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 10) PRIMARY KEY)", "tsql": "CREATE TABLE tbl (id INTEGER NOT NULL IDENTITY(10, 1) PRIMARY KEY)", }, + write={ + "databricks": "CREATE TABLE tbl (id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 10 INCREMENT BY 1) PRIMARY KEY)", + }, ) self.validate_all( "SELECT * INTO foo.bar.baz FROM (SELECT * FROM a.b.c) AS temp", @@ -561,22 +607,10 @@ class TestTSQL(Validator): self.validate_all( "CREATE TABLE #mytemp (a INTEGER, b CHAR(2), c TIME(4), d FLOAT(24))", write={ - "spark": "CREATE TEMPORARY TABLE mytemp (a INT, b CHAR(2), c TIMESTAMP, d FLOAT)", + "spark": "CREATE TEMPORARY TABLE mytemp (a INT, b CHAR(2), c TIMESTAMP, d FLOAT) USING PARQUET", "tsql": "CREATE TABLE #mytemp (a INTEGER, b CHAR(2), c TIME(4), d FLOAT(24))", }, ) - self.validate_all( - "CREATE TABLE #mytemptable (a INTEGER)", - read={ - "duckdb": "CREATE TEMPORARY TABLE mytemptable (a INT)", - }, - write={ - "tsql": "CREATE TABLE #mytemptable (a INTEGER)", - "snowflake": "CREATE TEMPORARY TABLE mytemptable (a INT)", - "duckdb": "CREATE TEMPORARY TABLE mytemptable (a INT)", - "oracle": "CREATE TEMPORARY TABLE mytemptable (a NUMBER)", - }, - ) def test_insert_cte(self): self.validate_all( |