Adding upstream version 23.12.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
efe1f986ea
commit
5d33af745d
93 changed files with 55455 additions and 52777 deletions
|
@ -93,6 +93,9 @@ class TestClickhouse(Validator):
|
|||
self.validate_identity("""SELECT JSONExtractString('{"x": {"y": 1}}', 'x', 'y')""")
|
||||
self.validate_identity("SELECT * FROM table LIMIT 1 BY a, b")
|
||||
self.validate_identity("SELECT * FROM table LIMIT 2 OFFSET 1 BY a, b")
|
||||
self.validate_identity(
|
||||
"SELECT id, quantileGK(100, 0.95)(reading) OVER (PARTITION BY id ORDER BY id RANGE BETWEEN 30000 PRECEDING AND CURRENT ROW) AS window FROM table"
|
||||
)
|
||||
|
||||
self.validate_identity(
|
||||
"SELECT $1$foo$1$",
|
||||
|
@ -409,6 +412,19 @@ class TestClickhouse(Validator):
|
|||
self.validate_identity("SELECT FORMAT")
|
||||
self.validate_identity("1 AS FORMAT").assert_is(exp.Alias)
|
||||
|
||||
self.validate_identity("SELECT DATE_FORMAT(NOW(), '%Y-%m-%d', '%T')")
|
||||
self.validate_all(
|
||||
"SELECT DATE_FORMAT(NOW(), '%Y-%m-%d')",
|
||||
read={
|
||||
"clickhouse": "SELECT formatDateTime(NOW(), '%Y-%m-%d')",
|
||||
"mysql": "SELECT DATE_FORMAT(NOW(), '%Y-%m-%d')",
|
||||
},
|
||||
write={
|
||||
"clickhouse": "SELECT DATE_FORMAT(NOW(), '%Y-%m-%d')",
|
||||
"mysql": "SELECT DATE_FORMAT(NOW(), '%Y-%m-%d')",
|
||||
},
|
||||
)
|
||||
|
||||
def test_cte(self):
|
||||
self.validate_identity("WITH 'x' AS foo SELECT foo")
|
||||
self.validate_identity("WITH ['c'] AS field_names SELECT field_names")
|
||||
|
@ -813,3 +829,30 @@ 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()"
|
||||
)
|
||||
|
||||
def test_agg_functions(self):
|
||||
def extract_agg_func(query):
|
||||
return parse_one(query, read="clickhouse").selects[0].this
|
||||
|
||||
self.assertIsInstance(
|
||||
extract_agg_func("select quantileGK(100, 0.95) OVER (PARTITION BY id) FROM table"),
|
||||
exp.AnonymousAggFunc,
|
||||
)
|
||||
self.assertIsInstance(
|
||||
extract_agg_func(
|
||||
"select quantileGK(100, 0.95)(reading) OVER (PARTITION BY id) FROM table"
|
||||
),
|
||||
exp.ParameterizedAgg,
|
||||
)
|
||||
self.assertIsInstance(
|
||||
extract_agg_func("select quantileGKIf(100, 0.95) OVER (PARTITION BY id) FROM table"),
|
||||
exp.CombinedAggFunc,
|
||||
)
|
||||
self.assertIsInstance(
|
||||
extract_agg_func(
|
||||
"select quantileGKIf(100, 0.95)(reading) OVER (PARTITION BY id) FROM table"
|
||||
),
|
||||
exp.CombinedParameterizedAgg,
|
||||
)
|
||||
|
||||
parse_one("foobar(x)").assert_is(exp.Anonymous)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue