summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_dialect.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-20 09:37:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-20 09:37:57 +0000
commit5c70c63284a8ff61607db1a51ac2829b74f71c1c (patch)
tree10a81ffbd8da8cae58e292848cbdd0550d08721d /tests/dialects/test_dialect.py
parentAdding upstream version 21.1.1. (diff)
downloadsqlglot-5c70c63284a8ff61607db1a51ac2829b74f71c1c.tar.xz
sqlglot-5c70c63284a8ff61607db1a51ac2829b74f71c1c.zip
Adding upstream version 21.1.2.upstream/21.1.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_dialect.py')
-rw-r--r--tests/dialects/test_dialect.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/dialects/test_dialect.py b/tests/dialects/test_dialect.py
index 4b1e2a7..b50fec8 100644
--- a/tests/dialects/test_dialect.py
+++ b/tests/dialects/test_dialect.py
@@ -729,7 +729,7 @@ class TestDialect(Validator):
write={
"duckdb": "TO_TIMESTAMP(x)",
"hive": "FROM_UNIXTIME(x)",
- "oracle": "TO_DATE('1970-01-01','YYYY-MM-DD') + (x / 86400)",
+ "oracle": "TO_DATE('1970-01-01', 'YYYY-MM-DD') + (x / 86400)",
"postgres": "TO_TIMESTAMP(x)",
"presto": "FROM_UNIXTIME(x)",
"starrocks": "FROM_UNIXTIME(x)",
@@ -2272,3 +2272,32 @@ SELECT
"tsql": "RAND()",
},
)
+
+ def test_array_any(self):
+ self.validate_all(
+ "ARRAY_ANY(arr, x -> pred)",
+ write={
+ "": "ARRAY_ANY(arr, x -> pred)",
+ "bigquery": "(ARRAY_LENGTH(arr) = 0 OR ARRAY_LENGTH(ARRAY(SELECT x FROM UNNEST(arr) AS x WHERE pred)) <> 0)",
+ "clickhouse": "(LENGTH(arr) = 0 OR LENGTH(arrayFilter(x -> pred, arr)) <> 0)",
+ "databricks": "(SIZE(arr) = 0 OR SIZE(FILTER(arr, x -> pred)) <> 0)",
+ "doris": UnsupportedError,
+ "drill": UnsupportedError,
+ "duckdb": "(ARRAY_LENGTH(arr) = 0 OR ARRAY_LENGTH(LIST_FILTER(arr, x -> pred)) <> 0)",
+ "hive": UnsupportedError,
+ "mysql": UnsupportedError,
+ "oracle": UnsupportedError,
+ "postgres": "(ARRAY_LENGTH(arr, 1) = 0 OR ARRAY_LENGTH(ARRAY(SELECT x FROM UNNEST(arr) AS _t(x) WHERE pred), 1) <> 0)",
+ "presto": "ANY_MATCH(arr, x -> pred)",
+ "redshift": UnsupportedError,
+ "snowflake": UnsupportedError,
+ "spark": "(SIZE(arr) = 0 OR SIZE(FILTER(arr, x -> pred)) <> 0)",
+ "spark2": "(SIZE(arr) = 0 OR SIZE(FILTER(arr, x -> pred)) <> 0)",
+ "sqlite": UnsupportedError,
+ "starrocks": UnsupportedError,
+ "tableau": UnsupportedError,
+ "teradata": "(CARDINALITY(arr) = 0 OR CARDINALITY(FILTER(arr, x -> pred)) <> 0)",
+ "trino": "ANY_MATCH(arr, x -> pred)",
+ "tsql": UnsupportedError,
+ },
+ )