Don not add const group by key for query with only having.

This commit is contained in:
Nikolai Kochetov 2021-09-13 13:35:36 +03:00
parent a5f1185197
commit f4b47ca194

View File

@ -90,12 +90,7 @@ void optimizeGroupBy(ASTSelectQuery * select_query, const NameSet & source_colum
const FunctionFactory & function_factory = FunctionFactory::instance();
if (!select_query->groupBy())
{
// If there is a HAVING clause without GROUP BY, make sure we have some aggregation happen.
if (select_query->having())
appendUnusedGroupByColumn(select_query, source_columns);
return;
}
const auto is_literal = [] (const ASTPtr & ast) -> bool
{