summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_clickhouse.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:35:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:35:50 +0000
commit8f1b330983bddb35e2ec61a5667a84318bad88ef (patch)
tree32b74e964839c34014d31ec828fc6521323b9edc /tests/dialects/test_clickhouse.py
parentAdding upstream version 23.13.7. (diff)
downloadsqlglot-8f1b330983bddb35e2ec61a5667a84318bad88ef.tar.xz
sqlglot-8f1b330983bddb35e2ec61a5667a84318bad88ef.zip
Adding upstream version 23.16.0.upstream/23.16.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.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/dialects/test_clickhouse.py b/tests/dialects/test_clickhouse.py
index af552d1..15adda8 100644
--- a/tests/dialects/test_clickhouse.py
+++ b/tests/dialects/test_clickhouse.py
@@ -425,6 +425,21 @@ class TestClickhouse(Validator):
},
)
+ self.validate_identity("ALTER TABLE visits DROP PARTITION 201901")
+ self.validate_identity("ALTER TABLE visits DROP PARTITION ALL")
+ self.validate_identity(
+ "ALTER TABLE visits DROP PARTITION tuple(toYYYYMM(toDate('2019-01-25')))"
+ )
+ self.validate_identity("ALTER TABLE visits DROP PARTITION ID '201901'")
+
+ self.validate_identity("ALTER TABLE visits REPLACE PARTITION 201901 FROM visits_tmp")
+ self.validate_identity("ALTER TABLE visits REPLACE PARTITION ALL FROM visits_tmp")
+ self.validate_identity(
+ "ALTER TABLE visits REPLACE PARTITION tuple(toYYYYMM(toDate('2019-01-25'))) FROM visits_tmp"
+ )
+ self.validate_identity("ALTER TABLE visits REPLACE PARTITION ID '201901' FROM visits_tmp")
+ self.validate_identity("ALTER TABLE visits ON CLUSTER test_cluster DROP COLUMN col1")
+
def test_cte(self):
self.validate_identity("WITH 'x' AS foo SELECT foo")
self.validate_identity("WITH ['c'] AS field_names SELECT field_names")
@@ -829,6 +844,9 @@ LIFETIME(MIN 0 MAX 0)""",
self.validate_identity(
"CREATE TABLE t1 (a String EPHEMERAL, b String EPHEMERAL func(), c String MATERIALIZED func(), d String ALIAS func()) ENGINE=TinyLog()"
)
+ self.validate_identity(
+ "CREATE TABLE t (a String, b String, c UInt64, PROJECTION p1 (SELECT a, sum(c) GROUP BY a, b), PROJECTION p2 (SELECT b, sum(c) GROUP BY b)) ENGINE=MergeTree()"
+ )
def test_agg_functions(self):
def extract_agg_func(query):
@@ -856,3 +874,8 @@ LIFETIME(MIN 0 MAX 0)""",
)
parse_one("foobar(x)").assert_is(exp.Anonymous)
+
+ def test_drop_on_cluster(self):
+ for creatable in ("DATABASE", "TABLE", "VIEW", "DICTIONARY", "FUNCTION"):
+ with self.subTest(f"Test DROP {creatable} ON CLUSTER"):
+ self.validate_identity(f"DROP {creatable} test ON CLUSTER test_cluster")