summaryrefslogtreecommitdiffstats
path: root/tests/dialects
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-27 10:46:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-27 10:46:36 +0000
commita8b22b4c5bdf9139a187c92b7b9f81bdeaa84888 (patch)
tree93b8523df3ce9e02e435f56e493bd9b724eb9c7c /tests/dialects
parentReleasing debian version 11.2.0-1. (diff)
downloadsqlglot-a8b22b4c5bdf9139a187c92b7b9f81bdeaa84888.tar.xz
sqlglot-a8b22b4c5bdf9139a187c92b7b9f81bdeaa84888.zip
Merging upstream version 11.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects')
-rw-r--r--tests/dialects/test_dialect.py11
-rw-r--r--tests/dialects/test_snowflake.py6
-rw-r--r--tests/dialects/test_spark.py7
-rw-r--r--tests/dialects/test_teradata.py2
4 files changed, 24 insertions, 2 deletions
diff --git a/tests/dialects/test_dialect.py b/tests/dialects/test_dialect.py
index 685dea4..3186390 100644
--- a/tests/dialects/test_dialect.py
+++ b/tests/dialects/test_dialect.py
@@ -285,6 +285,10 @@ class TestDialect(Validator):
read={"oracle": "CAST(a AS NUMBER)"},
write={"oracle": "CAST(a AS NUMBER)"},
)
+ self.validate_all(
+ "CAST('127.0.0.1/32' AS INET)",
+ read={"postgres": "INET '127.0.0.1/32'"},
+ )
def test_if_null(self):
self.validate_all(
@@ -509,7 +513,7 @@ class TestDialect(Validator):
"starrocks": "DATE_ADD(x, INTERVAL 1 DAY)",
},
write={
- "bigquery": "DATE_ADD(x, INTERVAL 1 'day')",
+ "bigquery": "DATE_ADD(x, INTERVAL 1 DAY)",
"drill": "DATE_ADD(x, INTERVAL 1 DAY)",
"duckdb": "x + INTERVAL 1 day",
"hive": "DATE_ADD(x, 1)",
@@ -526,7 +530,7 @@ class TestDialect(Validator):
self.validate_all(
"DATE_ADD(x, 1)",
write={
- "bigquery": "DATE_ADD(x, INTERVAL 1 'day')",
+ "bigquery": "DATE_ADD(x, INTERVAL 1 DAY)",
"drill": "DATE_ADD(x, INTERVAL 1 DAY)",
"duckdb": "x + INTERVAL 1 DAY",
"hive": "DATE_ADD(x, 1)",
@@ -540,6 +544,7 @@ class TestDialect(Validator):
"DATE_TRUNC('day', x)",
write={
"mysql": "DATE(x)",
+ "snowflake": "DATE_TRUNC('day', x)",
},
)
self.validate_all(
@@ -576,6 +581,7 @@ class TestDialect(Validator):
"DATE_TRUNC('year', x)",
read={
"bigquery": "DATE_TRUNC(x, year)",
+ "snowflake": "DATE_TRUNC(year, x)",
"starrocks": "DATE_TRUNC('year', x)",
"spark": "TRUNC(x, 'year')",
},
@@ -583,6 +589,7 @@ class TestDialect(Validator):
"bigquery": "DATE_TRUNC(x, year)",
"mysql": "STR_TO_DATE(CONCAT(YEAR(x), ' 1 1'), '%Y %c %e')",
"postgres": "DATE_TRUNC('year', x)",
+ "snowflake": "DATE_TRUNC('year', x)",
"starrocks": "DATE_TRUNC('year', x)",
"spark": "TRUNC(x, 'year')",
},
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 9e22527..a934c78 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -397,6 +397,12 @@ class TestSnowflake(Validator):
},
)
+ self.validate_all(
+ "CREATE TABLE a (b INT)",
+ read={"teradata": "CREATE MULTISET TABLE a (b INT)"},
+ write={"snowflake": "CREATE TABLE a (b INT)"},
+ )
+
def test_user_defined_functions(self):
self.validate_all(
"CREATE FUNCTION a(x DATE, y BIGINT) RETURNS ARRAY LANGUAGE JAVASCRIPT AS $$ SELECT 1 $$",
diff --git a/tests/dialects/test_spark.py b/tests/dialects/test_spark.py
index be74a27..9328eaa 100644
--- a/tests/dialects/test_spark.py
+++ b/tests/dialects/test_spark.py
@@ -214,6 +214,13 @@ TBLPROPERTIES (
self.validate_identity("TRIM(TRAILING 'SL' FROM 'SSparkSQLS')")
self.validate_all(
+ "SELECT DATE_ADD(my_date_column, 1)",
+ write={
+ "spark": "SELECT DATE_ADD(my_date_column, 1)",
+ "bigquery": "SELECT DATE_ADD(my_date_column, INTERVAL 1 DAY)",
+ },
+ )
+ self.validate_all(
"AGGREGATE(my_arr, 0, (acc, x) -> acc + x, s -> s * 2)",
write={
"trino": "REDUCE(my_arr, 0, (acc, x) -> acc + x, s -> s * 2)",
diff --git a/tests/dialects/test_teradata.py b/tests/dialects/test_teradata.py
index ab87eef..dd251ab 100644
--- a/tests/dialects/test_teradata.py
+++ b/tests/dialects/test_teradata.py
@@ -35,6 +35,8 @@ class TestTeradata(Validator):
write={"teradata": "SELECT a FROM b"},
)
+ self.validate_identity("CREATE VOLATILE TABLE a (b INT)")
+
def test_insert(self):
self.validate_all(
"INS INTO x SELECT * FROM y", write={"teradata": "INSERT INTO x SELECT * FROM y"}