From 15deaf7255a32717a7f15a35e0229ecd720318fe Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Thu, 5 Mar 2026 13:56:55 +0100 Subject: [PATCH 1/2] Allow cluster request with undefined cluster on secondary nodes --- src/TableFunctions/ITableFunctionCluster.h | 5 ++++- tests/integration/test_s3_cluster/test.py | 25 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/TableFunctions/ITableFunctionCluster.h b/src/TableFunctions/ITableFunctionCluster.h index 975322d054b3..d40246452555 100644 --- a/src/TableFunctions/ITableFunctionCluster.h +++ b/src/TableFunctions/ITableFunctionCluster.h @@ -76,7 +76,10 @@ class ITableFunctionCluster : public Base /// Cluster name is always the first cluster_name = checkAndGetLiteralArgument(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 diff --git a/tests/integration/test_s3_cluster/test.py b/tests/integration/test_s3_cluster/test.py index d607f390ba3c..18f5f0609e94 100644 --- a/tests/integration/test_s3_cluster/test.py +++ b/tests/integration/test_s3_cluster/test.py @@ -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, @@ -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 From ded9261650edb30c55ce6c1c0be647b5e5795a40 Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Thu, 5 Mar 2026 14:07:44 +0100 Subject: [PATCH 2/2] Fix test --- .../test_s3_cluster/configs/cluster1.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/integration/test_s3_cluster/configs/cluster1.xml diff --git a/tests/integration/test_s3_cluster/configs/cluster1.xml b/tests/integration/test_s3_cluster/configs/cluster1.xml new file mode 100644 index 000000000000..ce96069a070a --- /dev/null +++ b/tests/integration/test_s3_cluster/configs/cluster1.xml @@ -0,0 +1,16 @@ + + + + + + s0_0_1 + 9000 + + + s0_1_0 + 9000 + + + + +