ClickHouse/tests/queries/0_stateless/02972_parallel_replicas_cte.sql

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

82 lines
3.5 KiB
MySQL
Raw Normal View History

DROP TABLE IF EXISTS pr_1;
DROP TABLE IF EXISTS pr_2;
2024-02-26 14:09:05 +00:00
DROP TABLE IF EXISTS numbers_1e6;
CREATE TABLE pr_1 (`a` UInt32) ENGINE = MergeTree ORDER BY a PARTITION BY a % 10 AS
SELECT 10 * intDiv(number, 10) + 1 FROM numbers(1_000);
CREATE TABLE pr_2 (`a` UInt32) ENGINE = MergeTree ORDER BY a AS
SELECT * FROM numbers(1_000);
WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100)
SELECT count() FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a;
WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100)
SELECT count() FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a
2024-09-06 15:27:46 +00:00
SETTINGS enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3;
2024-07-12 12:49:26 +00:00
-- Testing that it is disabled for enable_analyzer=0. With analyzer it will be supported (with correct result)
WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100)
SELECT count() FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a
2024-09-06 15:27:46 +00:00
SETTINGS enable_analyzer = 0, enable_parallel_replicas = 2, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3; -- { serverError SUPPORT_IS_DISABLED }
2024-09-06 15:27:46 +00:00
-- Disabled for any value of enable_parallel_replicas != 1, not just 2
WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100)
SELECT count() FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a
2024-09-06 15:27:46 +00:00
SETTINGS enable_analyzer = 0, enable_parallel_replicas = 512, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3; -- { serverError SUPPORT_IS_DISABLED }
2024-02-01 10:46:55 +00:00
-- Sanitizer
SELECT count() FROM pr_2 JOIN numbers(10) as pr_1 ON pr_2.a = pr_1.number
2024-09-06 15:27:46 +00:00
SETTINGS enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3;
2024-02-01 10:46:55 +00:00
2024-02-26 14:09:05 +00:00
-- Parallel replicas detection should work inside subqueries
SELECT *
FROM
(
WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100)
SELECT count() FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a
)
2024-09-06 15:27:46 +00:00
SETTINGS enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3;
2024-02-26 14:09:05 +00:00
-- Subquery + subquery
SELECT count()
FROM
(
SELECT c + 1
FROM
(
WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100)
2024-02-26 14:09:05 +00:00
SELECT count() as c FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a
)
)
2024-09-06 15:27:46 +00:00
SETTINGS enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3;
2024-02-26 14:09:05 +00:00
CREATE TABLE numbers_1e3
2024-02-26 14:09:05 +00:00
(
`n` UInt64
)
ENGINE = MergeTree
ORDER BY n
AS SELECT * FROM numbers(1_000);
2024-02-26 14:09:05 +00:00
-- Same but nested CTE's
WITH
cte1 AS
(
SELECT n
FROM numbers_1e3
2024-02-26 14:09:05 +00:00
),
cte2 AS
(
SELECT n
FROM numbers_1e3
2024-02-26 14:09:05 +00:00
WHERE n IN (cte1)
)
SELECT count()
FROM cte2
2024-09-06 15:27:46 +00:00
SETTINGS enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3;
2024-02-26 14:09:05 +00:00
DROP TABLE IF EXISTS numbers_1e6;
DROP TABLE IF EXISTS pr_1;
DROP TABLE IF EXISTS pr_2;