Merge pull request #64220 from yariks5s/test_distributed_table_exception

Add test for #37090
This commit is contained in:
Yarik Briukhovetskyi 2024-06-05 10:49:31 +00:00 committed by GitHub
commit 73d0b51283
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<clickhouse>
<remote_servers>
<localhost_cluster>
<shard>
<replica>
<host>localhost</host>
<port>9000</port>
</replica>
</shard>
</localhost_cluster>
</remote_servers>
</clickhouse>

View File

@ -0,0 +1,35 @@
import pytest
from helpers.cluster import ClickHouseCluster
import logging
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance("node", main_configs=["configs/clusters.xml"])
@pytest.fixture(scope="module")
def start_cluster():
try:
logging.info("Starting cluster...")
cluster.start()
logging.info("Cluster started")
yield cluster
finally:
cluster.shutdown()
@pytest.mark.parametrize("prefer_localhost_replica", [0, 1])
def test_distributed_table_with_alias(start_cluster, prefer_localhost_replica):
node.query(
"""
DROP TABLE IF EXISTS local;
DROP TABLE IF EXISTS dist;
CREATE TABLE local(`dummy` UInt8) ENGINE = MergeTree ORDER BY tuple();
CREATE TABLE dist AS local ENGINE = Distributed(localhost_cluster, currentDatabase(), local);
"""
)
node.query(
"WITH 'Hello' AS `alias` SELECT `alias` FROM dist GROUP BY `alias`;",
settings={"prefer_localhost_replica": prefer_localhost_replica},
)