From a497d4d4620248d675e58dfdaa5177de25fb2cb1 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 12 Apr 2021 22:15:58 +0300 Subject: [PATCH] Do not perform optimize_skip_unused_shards for cluster with one node --- src/Storages/StorageDistributed.cpp | 2 +- .../01812_optimize_skip_unused_shards_single_node.reference | 0 .../01812_optimize_skip_unused_shards_single_node.sql | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.reference create mode 100644 tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.sql diff --git a/src/Storages/StorageDistributed.cpp b/src/Storages/StorageDistributed.cpp index 52c8c4f79e0..9fefcdaac49 100644 --- a/src/Storages/StorageDistributed.cpp +++ b/src/Storages/StorageDistributed.cpp @@ -468,7 +468,7 @@ QueryProcessingStage::Enum StorageDistributed::getQueryProcessingStage( /// Always calculate optimized cluster here, to avoid conditions during read() /// (Anyway it will be calculated in the read()) - if (settings.optimize_skip_unused_shards) + if (getClusterQueriedNodes(settings, cluster) > 1 && settings.optimize_skip_unused_shards) { ClusterPtr optimized_cluster = getOptimizedCluster(local_context, metadata_snapshot, query_info.query); if (optimized_cluster) diff --git a/tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.reference b/tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.sql b/tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.sql new file mode 100644 index 00000000000..c39947f2c04 --- /dev/null +++ b/tests/queries/0_stateless/01812_optimize_skip_unused_shards_single_node.sql @@ -0,0 +1,3 @@ +-- remote() does not have sharding key, while force_optimize_skip_unused_shards=2 requires from table to have it. +-- But due to only one node, everything works. +select * from remote('127.1', system.one) settings optimize_skip_unused_shards=1, force_optimize_skip_unused_shards=2 format Null;