diff --git a/src/Interpreters/ClusterProxy/SelectStreamFactory.cpp b/src/Interpreters/ClusterProxy/SelectStreamFactory.cpp index a47874c475a..5d35525aee9 100644 --- a/src/Interpreters/ClusterProxy/SelectStreamFactory.cpp +++ b/src/Interpreters/ClusterProxy/SelectStreamFactory.cpp @@ -35,11 +35,9 @@ namespace ClusterProxy SelectStreamFactory::SelectStreamFactory( const Block & header_, - QueryProcessingStage::Enum processed_stage_, - bool has_virtual_shard_num_column_) - : header(header_), - processed_stage{processed_stage_}, - has_virtual_shard_num_column(has_virtual_shard_num_column_) + QueryProcessingStage::Enum processed_stage_) + : header(header_) + , processed_stage{processed_stage_} { } @@ -102,19 +100,15 @@ void SelectStreamFactory::createForShard( Shards & remote_shards, UInt32 shard_count) { - auto modified_query_ast = query_ast->clone(); - if (has_virtual_shard_num_column) - VirtualColumnUtils::rewriteEntityInAst(modified_query_ast, "_shard_num", shard_info.shard_num, "toUInt32"); - auto emplace_local_stream = [&]() { - local_plans.emplace_back(createLocalPlan(modified_query_ast, header, context, processed_stage, shard_info.shard_num, shard_count)); + local_plans.emplace_back(createLocalPlan(query_ast, header, context, processed_stage, shard_info.shard_num, shard_count)); }; auto emplace_remote_stream = [&](bool lazy = false, UInt32 local_delay = 0) { remote_shards.emplace_back(Shard{ - .query = modified_query_ast, + .query = query_ast, .header = header, .shard_num = shard_info.shard_num, .num_replicas = shard_info.getAllNodeCount(), diff --git a/src/Interpreters/ClusterProxy/SelectStreamFactory.h b/src/Interpreters/ClusterProxy/SelectStreamFactory.h index dda6fb96f01..55e81feee33 100644 --- a/src/Interpreters/ClusterProxy/SelectStreamFactory.h +++ b/src/Interpreters/ClusterProxy/SelectStreamFactory.h @@ -16,8 +16,7 @@ class SelectStreamFactory final : public IStreamFactory public: SelectStreamFactory( const Block & header_, - QueryProcessingStage::Enum processed_stage_, - bool has_virtual_shard_num_column_); + QueryProcessingStage::Enum processed_stage_); void createForShard( const Cluster::ShardInfo & shard_info, @@ -32,8 +31,6 @@ public: private: const Block header; QueryProcessingStage::Enum processed_stage; - - bool has_virtual_shard_num_column = false; }; } diff --git a/src/Storages/StorageDistributed.cpp b/src/Storages/StorageDistributed.cpp index bcb12cc86b0..543ec9ee14a 100644 --- a/src/Storages/StorageDistributed.cpp +++ b/src/Storages/StorageDistributed.cpp @@ -308,7 +308,7 @@ NamesAndTypesList StorageDistributed::getVirtuals() const NameAndTypePair("_part_uuid", std::make_shared()), NameAndTypePair("_partition_id", std::make_shared()), NameAndTypePair("_sample_factor", std::make_shared()), - NameAndTypePair("_shard_num", std::make_shared()), + NameAndTypePair("_shard_num", std::make_shared()), /// deprecated }; } @@ -605,8 +605,8 @@ Pipe StorageDistributed::read( void StorageDistributed::read( QueryPlan & query_plan, - const Names & column_names, - const StorageMetadataPtr & metadata_snapshot, + const Names &, + const StorageMetadataPtr &, SelectQueryInfo & query_info, ContextPtr local_context, QueryProcessingStage::Enum processed_stage, @@ -635,10 +635,6 @@ void StorageDistributed::read( return; } - bool has_virtual_shard_num_column = std::find(column_names.begin(), column_names.end(), "_shard_num") != column_names.end(); - if (has_virtual_shard_num_column && !isVirtualColumn("_shard_num", metadata_snapshot)) - has_virtual_shard_num_column = false; - StorageID main_table = StorageID::createEmpty(); if (!remote_table_function_ptr) main_table = StorageID{remote_database, remote_table}; @@ -646,8 +642,7 @@ void StorageDistributed::read( ClusterProxy::SelectStreamFactory select_stream_factory = ClusterProxy::SelectStreamFactory( header, - processed_stage, - has_virtual_shard_num_column); + processed_stage); ClusterProxy::executeQuery( query_plan, header, processed_stage,