Update executeQuery.cpp

This commit is contained in:
alexey-milovidov 2021-08-27 00:59:58 +03:00 committed by GitHub
parent 7c66ad051d
commit 3d38604c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -661,14 +661,20 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem.client_info = client_info;
std::bernoulli_distribution should_write_log{
settings.log_queries_probability};
context->setSetting("log_queries", settings.log_queries && should_write_log(thread_local_rng));
context->setSetting("log_queries_probability", 1.0);
bool log_queries = settings.log_queries && !internal;
/// There is an option of probablistic logging of queries.
/// If it is used - do the random sampling and "collapse" the settings.
/// It allows to consistently log queries with all the subqueries in distributed query processing
/// (subqueries on remote nodes will receive these "collapsed" settings)
if (log_queries && settings.log_queries_probability < 1.0)
{
std::bernoulli_distribution should_write_log{settings.log_queries_probability};
context->setSetting("log_queries", settings.log_queries && should_write_log(thread_local_rng));
context->setSetting("log_queries_probability", 1.0);
}
/// Log into system table start of query execution, if need.
if (log_queries)
{