diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-11 12:46:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-11 12:46:06 +0000 |
commit | 9dae42c19381cf27dc56bd932aebd780aa66722b (patch) | |
tree | d70521fc9bf401e225f567a2d6acf1c1e4add2fd /tests/dialects/test_clickhouse.py | |
parent | Adding upstream version 15.0.0. (diff) | |
download | sqlglot-9dae42c19381cf27dc56bd932aebd780aa66722b.tar.xz sqlglot-9dae42c19381cf27dc56bd932aebd780aa66722b.zip |
Adding upstream version 15.2.0.upstream/15.2.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.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/tests/dialects/test_clickhouse.py b/tests/dialects/test_clickhouse.py index b6a7765..f5372d9 100644 --- a/tests/dialects/test_clickhouse.py +++ b/tests/dialects/test_clickhouse.py @@ -39,8 +39,17 @@ class TestClickhouse(Validator): self.validate_identity( "CREATE TABLE test (id UInt8) ENGINE=AggregatingMergeTree() ORDER BY tuple()" ) + self.validate_identity( + "CREATE TABLE test ON CLUSTER default (id UInt8) ENGINE=AggregatingMergeTree() ORDER BY tuple()" + ) + self.validate_identity( + "CREATE MATERIALIZED VIEW test_view ON CLUSTER cl1 (id UInt8) ENGINE=AggregatingMergeTree() ORDER BY tuple() AS SELECT * FROM test_data" + ) self.validate_all( + r"'Enum8(\'Sunday\' = 0)'", write={"clickhouse": "'Enum8(''Sunday'' = 0)'"} + ) + self.validate_all( "SELECT uniq(x) FROM (SELECT any(y) AS x FROM (SELECT 1 AS y))", read={ "bigquery": "SELECT APPROX_COUNT_DISTINCT(x) FROM (SELECT ANY_VALUE(y) x FROM (SELECT 1 y))", @@ -395,3 +404,91 @@ SET }, pretty=True, ) + self.validate_all( + """ + CREATE DICTIONARY discounts_dict ( + advertiser_id UInt64, + discount_start_date Date, + discount_end_date Date, + amount Float64 + ) + PRIMARY KEY id + SOURCE(CLICKHOUSE(TABLE 'discounts')) + LIFETIME(MIN 1 MAX 1000) + LAYOUT(RANGE_HASHED(range_lookup_strategy 'max')) + RANGE(MIN discount_start_date MAX discount_end_date) + """, + write={ + "clickhouse": """CREATE DICTIONARY discounts_dict ( + advertiser_id UInt64, + discount_start_date DATE, + discount_end_date DATE, + amount Float64 +) +PRIMARY KEY (id) +SOURCE(CLICKHOUSE( + TABLE 'discounts' +)) +LIFETIME(MIN 1 MAX 1000) +LAYOUT(RANGE_HASHED( + range_lookup_strategy 'max' +)) +RANGE(MIN discount_start_date MAX discount_end_date)""", + }, + pretty=True, + ) + self.validate_all( + """ + CREATE DICTIONARY my_ip_trie_dictionary ( + prefix String, + asn UInt32, + cca2 String DEFAULT '??' + ) + PRIMARY KEY prefix + SOURCE(CLICKHOUSE(TABLE 'my_ip_addresses')) + LAYOUT(IP_TRIE) + LIFETIME(3600); + """, + write={ + "clickhouse": """CREATE DICTIONARY my_ip_trie_dictionary ( + prefix TEXT, + asn UInt32, + cca2 TEXT DEFAULT '??' +) +PRIMARY KEY (prefix) +SOURCE(CLICKHOUSE( + TABLE 'my_ip_addresses' +)) +LAYOUT(IP_TRIE()) +LIFETIME(MIN 0 MAX 3600)""", + }, + pretty=True, + ) + self.validate_all( + """ + CREATE DICTIONARY polygons_test_dictionary + ( + key Array(Array(Array(Tuple(Float64, Float64)))), + name String + ) + PRIMARY KEY key + SOURCE(CLICKHOUSE(TABLE 'polygons_test_table')) + LAYOUT(POLYGON(STORE_POLYGON_KEY_COLUMN 1)) + LIFETIME(0); + """, + write={ + "clickhouse": """CREATE DICTIONARY polygons_test_dictionary ( + key Array(Array(Array(Tuple(Float64, Float64)))), + name TEXT +) +PRIMARY KEY (key) +SOURCE(CLICKHOUSE( + TABLE 'polygons_test_table' +)) +LAYOUT(POLYGON( + STORE_POLYGON_KEY_COLUMN 1 +)) +LIFETIME(MIN 0 MAX 0)""", + }, + pretty=True, + ) |