This commit is contained in:
Nikita Taranov 2022-12-10 13:28:21 +01:00 committed by GitHub
parent e0a6ccc830
commit 3e3738bd49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -254,7 +254,7 @@ void ExpressionAnalyzer::analyzeAggregation(ActionsDAGPtr & temp_actions)
auto * select_query = query->as<ASTSelectQuery>();
makeAggregateDescriptions(temp_actions, aggregate_descriptions);
has_aggregation = !aggregate_descriptions.empty() || (select_query && (select_query->groupBy() || select_query->having()));
has_aggregation = !aggregate_descriptions.empty() || (select_query && select_query->groupBy());
if (!has_aggregation)
{
@ -411,7 +411,7 @@ void ExpressionAnalyzer::analyzeAggregation(ActionsDAGPtr & temp_actions)
if (group_asts.empty())
{
select_query->setExpression(ASTSelectQuery::Expression::GROUP_BY, {});
has_aggregation = select_query->having() || !aggregate_descriptions.empty();
has_aggregation = !aggregate_descriptions.empty();
}
}

View File

@ -0,0 +1,9 @@
select number from numbers_mt(10) having number >= 9;
select count() from numbers_mt(100) having count() > 1;
select queryID() as t from numbers(10) with totals having t = initialQueryID(); -- { serverError 48 }
-- this query works despite 'with total' doesn't make any sense due to this logic:
-- https://github.com/ClickHouse/ClickHouse/blob/master/src/Interpreters/InterpreterSelectQuery.cpp#L608-L610
select count() from (select queryID() as t from remote('127.0.0.{1..3}', numbers(10)) with totals having t = initialQueryID()) settings prefer_localhost_replica = 1;