ClickHouse/tests/queries/0_stateless/03146_tpc_ds_grouping.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.4 KiB
MySQL
Raw Normal View History

2024-05-06 10:39:52 +00:00
-- https://github.com/ClickHouse/ClickHouse/issues/46335
2024-07-12 12:49:26 +00:00
SET enable_analyzer = 1;
2024-05-06 10:39:52 +00:00
SELECT
key_a + key_b AS d,
rank() OVER () AS f
FROM
(
SELECT
rand() % 10 AS key_a,
rand(1) % 5 AS key_b,
number
FROM numbers(100)
)
GROUP BY
key_a,
key_b
WITH ROLLUP
ORDER BY multiIf(d = 0, key_a, NULL) ASC
FORMAT Null;
SELECT
key_a + key_b AS d,
rank() OVER (PARTITION BY key_a + key_b) AS f
FROM
(
SELECT
rand() % 10 AS key_a,
rand(1) % 5 AS key_b,
number
FROM numbers(100)
)
GROUP BY
key_a,
key_b
WITH ROLLUP
ORDER BY multiIf(d = 0, key_a, NULL) ASC
FORMAT Null;
SELECT
grouping(key_a) + grouping(key_b) AS d,
rank() OVER (PARTITION BY grouping(key_a) + grouping(key_b), multiIf(grouping(key_b) = 0, key_a, NULL)) AS f
FROM
(
SELECT
rand() % 10 AS key_a,
rand(1) % 5 AS key_b,
number
FROM numbers(100)
)
GROUP BY
key_a,
key_b
WITH ROLLUP
ORDER BY multiIf(d = 0, key_a, NULL) ASC
FORMAT Null;
SELECT grouping(key_a) + grouping(key_b) AS d
FROM
(
SELECT
rand() % 10 AS key_a,
rand(toLowCardinality(1)) % 5 AS key_b,
number
FROM numbers(100)
)
GROUP BY
key_a,
key_b
WITH ROLLUP
FORMAT Null;