summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_snowflake.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:50:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:50:21 +0000
commitda8fc943704a221b86f0f6938f4131f0dd679f82 (patch)
treebef7144499ea444319403ba8dbf68480ae3a4e39 /tests/dialects/test_snowflake.py
parentAdding upstream version 23.10.0. (diff)
downloadsqlglot-da8fc943704a221b86f0f6938f4131f0dd679f82.tar.xz
sqlglot-da8fc943704a221b86f0f6938f4131f0dd679f82.zip
Adding upstream version 23.12.1.upstream/23.12.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_snowflake.py')
-rw-r--r--tests/dialects/test_snowflake.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index b652541..1cbf68c 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -456,7 +456,7 @@ WHERE
},
write={
"": f"SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x NULLS LAST){suffix}",
- "duckdb": f"SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x){suffix}",
+ "duckdb": f"SELECT QUANTILE_CONT(x, 0.5 ORDER BY x){suffix}",
"postgres": f"SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x){suffix}",
"snowflake": f"SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x){suffix}",
},
@@ -821,6 +821,13 @@ WHERE
"snowflake": "CASE WHEN x = a OR (x IS NULL AND a IS NULL) THEN b WHEN x = c OR (x IS NULL AND c IS NULL) THEN d ELSE e END",
},
)
+ self.validate_all(
+ "SELECT LISTAGG(col1, ', ') WITHIN GROUP (ORDER BY col2) FROM t",
+ write={
+ "duckdb": "SELECT GROUP_CONCAT(col1, ', ' ORDER BY col2) FROM t",
+ "snowflake": "SELECT LISTAGG(col1, ', ') WITHIN GROUP (ORDER BY col2) FROM t",
+ },
+ )
def test_null_treatment(self):
self.validate_all(
@@ -1038,11 +1045,17 @@ WHERE
"SELECT CAST('2019-02-28' AS DATE) + INTERVAL '1 day, 1 year'",
)
- self.validate_identity("DATE(x)").assert_is(exp.Anonymous)
- self.validate_identity("TO_DATE(x)").assert_is(exp.Anonymous)
- self.validate_identity("TRY_TO_DATE(x)").assert_is(exp.Anonymous)
+ self.validate_identity("TO_DATE(x)").assert_is(exp.TsOrDsToDate)
+ self.validate_identity("TRY_TO_DATE(x)").assert_is(exp.TsOrDsToDate)
self.validate_all(
+ "DATE(x)",
+ write={
+ "duckdb": "CAST(x AS DATE)",
+ "snowflake": "TO_DATE(x)",
+ },
+ )
+ self.validate_all(
"TO_DATE(x, 'MM-DD-YYYY')",
write={
"snowflake": "TO_DATE(x, 'mm-DD-yyyy')",
@@ -1490,7 +1503,7 @@ FROM persons AS p, LATERAL FLATTEN(input => p.c, path => 'contact') AS _flattene
write={
"bigquery": "REGEXP_EXTRACT(subject, pattern, pos, occ)",
"hive": "REGEXP_EXTRACT(subject, pattern, group)",
- "presto": "REGEXP_EXTRACT(subject, pattern, group)",
+ "presto": 'REGEXP_EXTRACT(subject, pattern, "group")',
"snowflake": "REGEXP_SUBSTR(subject, pattern, pos, occ, params, group)",
"spark": "REGEXP_EXTRACT(subject, pattern, group)",
},