diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-27 10:46:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-27 10:46:33 +0000 |
commit | aa1d1f1ea72887a3efb78f4950e27bc79dfa3766 (patch) | |
tree | a9f5bf5ab14c69d011e21d40f8504c4f94a8de72 /tests/dialects | |
parent | Adding upstream version 11.2.0. (diff) | |
download | sqlglot-aa1d1f1ea72887a3efb78f4950e27bc79dfa3766.tar.xz sqlglot-aa1d1f1ea72887a3efb78f4950e27bc79dfa3766.zip |
Adding upstream version 11.2.3.upstream/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.py | 11 | ||||
-rw-r--r-- | tests/dialects/test_snowflake.py | 6 | ||||
-rw-r--r-- | tests/dialects/test_spark.py | 7 | ||||
-rw-r--r-- | tests/dialects/test_teradata.py | 2 |
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"} |