summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_clickhouse.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:48:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:48:08 +0000
commitb737ee75da2515a4a53956e41ae85e29dd67f21d (patch)
tree3896f4cac8aebc31f5cdb32a111fa801aba7ca22 /tests/dialects/test_clickhouse.py
parentAdding upstream version 17.7.0. (diff)
downloadsqlglot-upstream/17.9.1.tar.xz
sqlglot-upstream/17.9.1.zip
Adding upstream version 17.9.1.upstream/17.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/dialects/test_clickhouse.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/dialects/test_clickhouse.py b/tests/dialects/test_clickhouse.py
index bc82645..16c10fe 100644
--- a/tests/dialects/test_clickhouse.py
+++ b/tests/dialects/test_clickhouse.py
@@ -6,6 +6,12 @@ class TestClickhouse(Validator):
dialect = "clickhouse"
def test_clickhouse(self):
+ expr = parse_one("count(x)")
+ self.assertEqual(expr.sql(dialect="clickhouse"), "COUNT(x)")
+ self.assertIsNone(expr._meta)
+
+ self.validate_identity("SELECT isNaN(1.0)")
+ self.validate_identity("SELECT startsWith('Spider-Man', 'Spi')")
self.validate_identity("SELECT xor(TRUE, FALSE)")
self.validate_identity("ATTACH DATABASE DEFAULT ENGINE = ORDINARY")
self.validate_identity("CAST(['hello'], 'Array(Enum8(''hello'' = 1))')")
@@ -162,7 +168,7 @@ class TestClickhouse(Validator):
ORDER BY loyalty ASC
""",
write={
- "clickhouse": "SELECT loyalty, COUNT() FROM hits LEFT SEMI JOIN users USING (UserID)"
+ "clickhouse": "SELECT loyalty, count() FROM hits LEFT SEMI JOIN users USING (UserID)"
+ " GROUP BY loyalty ORDER BY loyalty"
},
)
@@ -247,7 +253,7 @@ class TestClickhouse(Validator):
for data_type in data_types:
self.validate_all(
f"pow(2, 32)::{data_type}",
- write={"clickhouse": f"CAST(POWER(2, 32) AS {data_type})"},
+ write={"clickhouse": f"CAST(pow(2, 32) AS {data_type})"},
)
def test_ddl(self):
@@ -304,8 +310,8 @@ GROUP BY
id,
toStartOfDay(timestamp)
SET
- max_hits = MAX(max_hits),
- sum_hits = SUM(sum_hits)""",
+ max_hits = max(max_hits),
+ sum_hits = sum(sum_hits)""",
},
pretty=True,
)
@@ -447,8 +453,8 @@ GROUP BY
k1,
k2
SET
- x = MAX(x),
- y = MIN(y)""",
+ x = max(x),
+ y = min(y)""",
},
pretty=True,
)