Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/TableFunctions/ITableFunctionCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ class ITableFunctionCluster : public Base
/// Cluster name is always the first
cluster_name = checkAndGetLiteralArgument<String>(args[0], "cluster_name");

if (!context->tryGetCluster(cluster_name))
/// Cluster resolving is not required for secondary query
const auto is_secondary_query = context->getClientInfo().query_kind == ClientInfo::QueryKind::SECONDARY_QUERY;

if (!is_secondary_query && !context->tryGetCluster(cluster_name))
throw Exception(ErrorCodes::CLUSTER_DOESNT_EXIST, "Requested cluster '{}' not found", cluster_name);

/// Just cut the first arg (cluster_name) and try to parse other table function arguments as is
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/test_s3_cluster/configs/cluster1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<clickhouse>
<remote_servers>
<undefined_cluster>
<shard>
<replica>
<host>s0_0_1</host>
<port>9000</port>
</replica>
<replica>
<host>s0_1_0</host>
<port>9000</port>
</replica>
</shard>
</undefined_cluster>
</remote_servers>
</clickhouse>
25 changes: 24 additions & 1 deletion tests/integration/test_s3_cluster/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def started_cluster():
cluster = ClickHouseCluster(__file__)
cluster.add_instance(
"s0_0_0",
main_configs=["configs/cluster.xml", "configs/named_collections.xml"],
main_configs=["configs/cluster.xml", "configs/named_collections.xml", "configs/cluster1.xml"],
user_configs=["configs/users.xml"],
macros={"replica": "node1", "shard": "shard1"},
with_minio=True,
Expand Down Expand Up @@ -1237,3 +1237,26 @@ def query_cycle():
node_to_shutdown.start_clickhouse()

assert errors == 0


def test_cluster_undefined_on_secondary_nodes(started_cluster):
node = started_cluster.instances["s0_0_0"]

expected_result = node.query(
f"""
SELECT * from s3(
'http://minio1:9001/root/data/{{clickhouse,database}}/*', 'minio', '{minio_secret_key}', 'CSV',
'name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))') ORDER BY (name, value, polygon)
"""
)

result = node.query(
f"""
SELECT * from s3Cluster(
'undefined_cluster',
'http://minio1:9001/root/data/{{clickhouse,database}}/*', 'minio', '{minio_secret_key}', 'CSV',
'name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))') ORDER BY (name, value, polygon)
"""
)

assert result == expected_result
Loading