Better diagnostic message formatting

This commit is contained in:
Igor Nikonov 2024-07-16 08:57:15 +00:00
parent 27db36cd4f
commit 4caf9b6e6f

View File

@ -22,7 +22,7 @@
#include <QueryPipeline/QueryPipelineBuilder.h> #include <QueryPipeline/QueryPipelineBuilder.h>
#include <Parsers/ASTFunction.h> #include <Parsers/ASTFunction.h>
#include <boost/algorithm/string/join.hpp> #include <fmt/format.h>
namespace DB namespace DB
{ {
@ -391,15 +391,11 @@ ReadFromParallelRemoteReplicasStep::ReadFromParallelRemoteReplicasStep(
std::vector<String> replicas; std::vector<String> replicas;
replicas.reserve(cluster->getShardsAddresses().front().size()); replicas.reserve(cluster->getShardsAddresses().front().size());
bool first_local = false;
for (const auto & addr : cluster->getShardsAddresses().front()) for (const auto & addr : cluster->getShardsAddresses().front())
{ {
/// skip first local /// skip first local
if (exclude_local_replica && addr.is_local && !first_local) if (exclude_local_replica && addr.is_local)
{
first_local = true;
continue; continue;
}
/// replace hostname with replica name if the hostname started with replica namespace, /// replace hostname with replica name if the hostname started with replica namespace,
/// it makes description shorter and more readable /// it makes description shorter and more readable
@ -409,7 +405,7 @@ ReadFromParallelRemoteReplicasStep::ReadFromParallelRemoteReplicasStep(
replicas.push_back(fmt::format("{}", addr.host_name)); replicas.push_back(fmt::format("{}", addr.host_name));
} }
auto description = fmt::format("Query: {} Replicas: ", formattedAST(query_ast)) + boost::algorithm::join(replicas, ", "); auto description = fmt::format("Query: {} Replicas: {}", formattedAST(query_ast), fmt::join(replicas, ", "));
setStepDescription(std::move(description)); setStepDescription(std::move(description));
} }
@ -489,13 +485,11 @@ void ReadFromParallelRemoteReplicasStep::initializePipeline(QueryPipelineBuilder
if (pools_to_use.empty()) if (pools_to_use.empty())
return; return;
{ std::vector<std::string_view> addresses;
String pool_addresses; addresses.reserve(pools_to_use.size());
for (const auto & pool : pools_to_use) for (const auto & pool : pools_to_use)
pool_addresses += pool->getAddress() + ";"; addresses.emplace_back(pool->getAddress());
LOG_DEBUG(getLogger("ReadFromParallelRemoteReplicasStep"), "Addresses to use: {}", fmt::join(addresses, ", "));
LOG_DEBUG(getLogger("ReadFromParallelRemoteReplicasStep"), "Addresses to use: {}", pool_addresses);
}
/// when using local plan for local replica, local replica has 0 number /// when using local plan for local replica, local replica has 0 number
size_t offset = (exclude_local_replica ? 1 : 0); size_t offset = (exclude_local_replica ? 1 : 0);