summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_clickhouse.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-24 08:03:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-24 08:03:45 +0000
commitca57dc468e5d8d0920e964d45ad25271ae6e633d (patch)
tree319d8bffcb5c3e9afe9e62beca9ef401480578d2 /tests/dialects/test_clickhouse.py
parentAdding upstream version 17.4.1. (diff)
downloadsqlglot-ca57dc468e5d8d0920e964d45ad25271ae6e633d.tar.xz
sqlglot-ca57dc468e5d8d0920e964d45ad25271ae6e633d.zip
Adding upstream version 17.7.0.upstream/17.7.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_clickhouse.py')
-rw-r--r--tests/dialects/test_clickhouse.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/dialects/test_clickhouse.py b/tests/dialects/test_clickhouse.py
index b0df4df..bc82645 100644
--- a/tests/dialects/test_clickhouse.py
+++ b/tests/dialects/test_clickhouse.py
@@ -6,6 +6,7 @@ class TestClickhouse(Validator):
dialect = "clickhouse"
def test_clickhouse(self):
+ self.validate_identity("SELECT xor(TRUE, FALSE)")
self.validate_identity("ATTACH DATABASE DEFAULT ENGINE = ORDINARY")
self.validate_identity("CAST(['hello'], 'Array(Enum8(''hello'' = 1))')")
self.validate_identity("SELECT x, COUNT() FROM y GROUP BY x WITH TOTALS")
@@ -53,6 +54,34 @@ class TestClickhouse(Validator):
)
self.validate_all(
+ "SELECT xor(1, 0)",
+ read={
+ "clickhouse": "SELECT xor(1, 0)",
+ "mysql": "SELECT 1 XOR 0",
+ },
+ write={
+ "mysql": "SELECT 1 XOR 0",
+ },
+ )
+ self.validate_all(
+ "SELECT xor(0, 1, xor(1, 0, 0))",
+ write={
+ "clickhouse": "SELECT xor(0, 1, xor(1, 0, 0))",
+ "mysql": "SELECT 0 XOR 1 XOR 1 XOR 0 XOR 0",
+ },
+ )
+ self.validate_all(
+ "SELECT xor(xor(1, 0), 1)",
+ read={
+ "clickhouse": "SELECT xor(xor(1, 0), 1)",
+ "mysql": "SELECT 1 XOR 0 XOR 1",
+ },
+ write={
+ "clickhouse": "SELECT xor(xor(1, 0), 1)",
+ "mysql": "SELECT 1 XOR 0 XOR 1",
+ },
+ )
+ self.validate_all(
"CONCAT(CASE WHEN COALESCE(CAST(a AS TEXT), '') IS NULL THEN COALESCE(CAST(a AS TEXT), '') ELSE CAST(COALESCE(CAST(a AS TEXT), '') AS TEXT) END, CASE WHEN COALESCE(CAST(b AS TEXT), '') IS NULL THEN COALESCE(CAST(b AS TEXT), '') ELSE CAST(COALESCE(CAST(b AS TEXT), '') AS TEXT) END)",
read={"postgres": "CONCAT(a, b)"},
)
@@ -137,6 +166,11 @@ class TestClickhouse(Validator):
+ " GROUP BY loyalty ORDER BY loyalty"
},
)
+ self.validate_identity("SELECT s, arr FROM arrays_test ARRAY JOIN arr")
+ self.validate_identity("SELECT s, arr, a FROM arrays_test LEFT ARRAY JOIN arr AS a")
+ self.validate_identity(
+ "SELECT s, arr_external FROM arrays_test ARRAY JOIN [1, 2, 3] AS arr_external"
+ )
def test_cte(self):
self.validate_identity("WITH 'x' AS foo SELECT foo")