Merge pull request #69146 from ClickHouse/pr-duplicate-announcement

Fix: parallel replicas duplicate announcement request
This commit is contained in:
Igor Nikonov 2024-09-04 10:27:20 +00:00 committed by GitHub
commit 042dbea094
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 73 additions and 1 deletions

View File

@ -1287,7 +1287,8 @@ void Planner::buildPlanForUnionNode()
for (const auto & query_node : union_queries_nodes)
{
Planner query_planner(query_node, select_query_options);
Planner query_planner(query_node, select_query_options, planner_context->getGlobalPlannerContext());
query_planner.buildQueryPlanIfNeeded();
for (const auto & row_policy : query_planner.getUsedRowPolicies())
used_row_policies.insert(row_policy);

View File

@ -0,0 +1,2 @@
0 Value_0
1 Value_1

View File

@ -0,0 +1,23 @@
DROP TABLE IF EXISTS test_table SYNC;
CREATE TABLE test_table
(
id UInt64,
value String
) ENGINE=ReplicatedMergeTree('/clickhouse/test/{database}/test_table', 'r1') ORDER BY tuple();
INSERT INTO test_table VALUES (0, 'Value_0'), (1, 'Value_1'), (2, 'Value_2');
DROP TABLE IF EXISTS test_table_for_in SYNC;
CREATE TABLE test_table_for_in
(
id UInt64
) ENGINE=ReplicatedMergeTree('/clickhouse/test/{database}/test_table_for_in', 'r1') ORDER BY tuple();
INSERT INTO test_table_for_in VALUES (0), (1);
SET allow_experimental_parallel_reading_from_replicas=1, max_parallel_replicas=3, cluster_for_parallel_replicas='test_cluster_one_shard_three_replicas_localhost';
SELECT id, value FROM test_table WHERE id IN (SELECT id FROM test_table_for_in UNION DISTINCT SELECT id FROM test_table_for_in);
DROP TABLE test_table SYNC;
DROP TABLE test_table_for_in SYNC;

View File

@ -0,0 +1 @@
CAT 2

View File

@ -0,0 +1,45 @@
DROP TABLE IF EXISTS ANIMAL SYNC;
CREATE TABLE ANIMAL ( ANIMAL Nullable(String) ) ENGINE = ReplicatedMergeTree('/clickhouse/test/{database}/animal', 'r1') ORDER BY tuple();
INSERT INTO ANIMAL (ANIMAL) VALUES ('CAT'), ('FISH'), ('DOG'), ('HORSE'), ('BIRD');
SET joined_subquery_requires_alias = 0;
SET allow_experimental_parallel_reading_from_replicas=1, max_parallel_replicas=3, cluster_for_parallel_replicas='test_cluster_one_shard_three_replicas_localhost';
SELECT *
FROM
(
SELECT
x.b AS x,
countDistinct(x.c) AS ANIMAL
FROM
(
SELECT
a.ANIMAL AS a,
'CAT' AS b,
c.ANIMAL AS c,
d.ANIMAL AS d
FROM ANIMAL AS a
INNER JOIN ANIMAL AS b ON a.ANIMAL = b.ANIMAL
LEFT JOIN ANIMAL AS c ON b.ANIMAL = c.ANIMAL
RIGHT JOIN
(
SELECT *
FROM ANIMAL
UNION ALL
SELECT *
FROM ANIMAL
UNION ALL
SELECT *
FROM ANIMAL
) AS d ON a.ANIMAL = d.ANIMAL
WHERE (d.ANIMAL != 'CAT') AND (c.ANIMAL != 'DOG') AND (b.ANIMAL != 'FISH')
) AS x
WHERE x.b >= 'CAT'
GROUP BY x.b
HAVING ANIMAL >= 0
) AS ANIMAL
WHERE ANIMAL.ANIMAL >= 0;
DROP TABLE ANIMAL SYNC;