Better replicas notation in plan description

This commit is contained in:
Igor Nikonov 2024-06-18 11:07:15 +00:00
parent 366de07856
commit 0ecefa6973

View File

@ -387,8 +387,8 @@ ReadFromParallelRemoteReplicasStep::ReadFromParallelRemoteReplicasStep(
{ {
chassert(cluster->getShardCount() == 1); chassert(cluster->getShardCount() == 1);
std::vector<String> description; std::vector<String> replicas;
description.push_back(fmt::format("query: {}", formattedAST(query_ast))); replicas.reserve(cluster->getShardsAddresses().front().size());
bool first_local = false; bool first_local = false;
for (const auto & addr : cluster->getShardsAddresses().front()) for (const auto & addr : cluster->getShardsAddresses().front())
@ -400,10 +400,16 @@ ReadFromParallelRemoteReplicasStep::ReadFromParallelRemoteReplicasStep(
continue; continue;
} }
description.push_back(fmt::format("Replica: {}", addr.host_name)); /// replace hostname with replica name if the hostname started with replica namespace,
/// it makes description shorter and more readable
if (!addr.database_replica_name.empty() && addr.host_name.starts_with(addr.database_replica_name))
replicas.push_back(fmt::format("{}", addr.database_replica_name));
else
replicas.push_back(fmt::format("{}", addr.host_name));
} }
setStepDescription(boost::algorithm::join(description, ", ")); auto description = fmt::format("Query: {} Replicas: ", formattedAST(query_ast)) + boost::algorithm::join(replicas, ", ");
setStepDescription(std::move(description));
} }
void ReadFromParallelRemoteReplicasStep::enforceSorting(SortDescription output_sort_description) void ReadFromParallelRemoteReplicasStep::enforceSorting(SortDescription output_sort_description)