mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
setting for totals threshold with AFTER_HAVING_AUTO. [#METR-10223]
This commit is contained in:
parent
d83ff9ceb2
commit
b0f079be0d
@ -20,7 +20,7 @@ class TotalsHavingBlockInputStream : public IProfilingBlockInputStream
|
|||||||
public:
|
public:
|
||||||
TotalsHavingBlockInputStream(BlockInputStreamPtr input_, const Names & keys_names_,
|
TotalsHavingBlockInputStream(BlockInputStreamPtr input_, const Names & keys_names_,
|
||||||
const AggregateDescriptions & aggregates_, bool overflow_row_, ExpressionActionsPtr expression_,
|
const AggregateDescriptions & aggregates_, bool overflow_row_, ExpressionActionsPtr expression_,
|
||||||
const std::string & filter_column_, TotalsMode totals_mode_, double auto_include_threshold_)
|
const std::string & filter_column_, TotalsMode totals_mode_, float auto_include_threshold_)
|
||||||
: aggregator(new Aggregator(keys_names_, aggregates_, overflow_row_)), overflow_row(overflow_row_),
|
: aggregator(new Aggregator(keys_names_, aggregates_, overflow_row_)), overflow_row(overflow_row_),
|
||||||
expression(expression_), filter_column_name(filter_column_), totals_mode(totals_mode_),
|
expression(expression_), filter_column_name(filter_column_), totals_mode(totals_mode_),
|
||||||
auto_include_threshold(auto_include_threshold_), passed_keys(0), total_keys(0)
|
auto_include_threshold(auto_include_threshold_), passed_keys(0), total_keys(0)
|
||||||
@ -47,7 +47,7 @@ private:
|
|||||||
ExpressionActionsPtr expression;
|
ExpressionActionsPtr expression;
|
||||||
String filter_column_name;
|
String filter_column_name;
|
||||||
TotalsMode totals_mode;
|
TotalsMode totals_mode;
|
||||||
double auto_include_threshold;
|
float auto_include_threshold;
|
||||||
size_t passed_keys;
|
size_t passed_keys;
|
||||||
size_t total_keys;
|
size_t total_keys;
|
||||||
|
|
||||||
|
@ -61,7 +61,9 @@ struct Settings
|
|||||||
M(SettingBool, replace_running_query, false) \
|
M(SettingBool, replace_running_query, false) \
|
||||||
\
|
\
|
||||||
M(SettingLoadBalancing, load_balancing, LoadBalancing::RANDOM) \
|
M(SettingLoadBalancing, load_balancing, LoadBalancing::RANDOM) \
|
||||||
|
\
|
||||||
M(SettingTotalsMode, totals_mode, TotalsMode::BEFORE_HAVING) \
|
M(SettingTotalsMode, totals_mode, TotalsMode::BEFORE_HAVING) \
|
||||||
|
M(SettingFloat, totals_auto_threshold, 0.5) \
|
||||||
\
|
\
|
||||||
/** Сэмплирование по умолчанию. Если равно 1, то отключено. */ \
|
/** Сэмплирование по умолчанию. Если равно 1, то отключено. */ \
|
||||||
M(SettingFloat, default_sample, 1.0) \
|
M(SettingFloat, default_sample, 1.0) \
|
||||||
|
@ -33,7 +33,7 @@ Block TotalsHavingBlockInputStream::readImpl()
|
|||||||
/** Если totals_mode==AFTER_HAVING_AUTO, нужно решить, добавлять ли в TOTALS агрегаты для строк,
|
/** Если totals_mode==AFTER_HAVING_AUTO, нужно решить, добавлять ли в TOTALS агрегаты для строк,
|
||||||
* не прошедших max_rows_to_group_by.
|
* не прошедших max_rows_to_group_by.
|
||||||
*/
|
*/
|
||||||
if (overflow_aggregates && 1. * passed_keys / total_keys >= auto_include_threshold)
|
if (overflow_aggregates && static_cast<float>(passed_keys) / total_keys >= auto_include_threshold)
|
||||||
addToTotals(current_totals, overflow_aggregates, nullptr);
|
addToTotals(current_totals, overflow_aggregates, nullptr);
|
||||||
finalize(current_totals);
|
finalize(current_totals);
|
||||||
totals = current_totals;
|
totals = current_totals;
|
||||||
|
@ -649,7 +649,7 @@ void InterpreterSelectQuery::executeTotalsAndHaving(BlockInputStreams & streams,
|
|||||||
query_analyzer->getAggregateInfo(key_names, aggregates);
|
query_analyzer->getAggregateInfo(key_names, aggregates);
|
||||||
streams[0] = maybeAsynchronous(new TotalsHavingBlockInputStream(
|
streams[0] = maybeAsynchronous(new TotalsHavingBlockInputStream(
|
||||||
streams[0], key_names, aggregates, overflow_row, expression,
|
streams[0], key_names, aggregates, overflow_row, expression,
|
||||||
has_having ? query.having_expression->getColumnName() : "", settings.totals_mode, .5),
|
has_having ? query.having_expression->getColumnName() : "", settings.totals_mode, settings.totals_auto_threshold),
|
||||||
settings.asynchronous);
|
settings.asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user