summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_tsql.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dialects/test_tsql.py')
-rw-r--r--tests/dialects/test_tsql.py60
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(