Change settings earlier

This commit is contained in:
Nikolay Degterinsky 2021-08-30 12:52:35 +03:00
parent 3d38604c55
commit c9adef001d

View File

@ -57,6 +57,7 @@
#include <Processors/Sources/SinkToOutputStream.h>
#include <random>
#include <common/logger_useful.h>
namespace ProfileEvents
@ -465,6 +466,18 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
setQuerySpecificSettings(ast, context);
/// There is an option of probabilistic 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 (!internal && settings.log_queries && settings.log_queries_probability < 1.0)
{
std::bernoulli_distribution should_write_log{settings.log_queries_probability};
context->setSetting("log_queries", should_write_log(thread_local_rng));
context->setSetting("log_queries_probability", 1.0);
}
/// Copy query into string. It will be written to log and presented in processlist. If an INSERT query, string will not include data to insertion.
String query(begin, query_end);
BlockIO res;
@ -663,18 +676,6 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
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)
{