mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #28975 from ClickHouse/check-what-if-do-not-add-const-agg-keys-with-having
Don not add const group by key for query with only having.
This commit is contained in:
commit
77a995381b
@ -91,12 +91,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
|
||||
{
|
||||
|
@ -0,0 +1,5 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
\N
|
@ -0,0 +1,10 @@
|
||||
SELECT count() AS cnt WHERE 0 HAVING cnt = 0;
|
||||
|
||||
select cnt from (select count() cnt where 0) where cnt = 0;
|
||||
|
||||
select cnt from (select count() cnt from system.one where 0) where cnt = 0;
|
||||
|
||||
select sum from (select sum(dummy) sum from system.one where 0) where sum = 0;
|
||||
|
||||
set aggregate_functions_null_for_empty=1;
|
||||
select sum from (select sum(dummy) sum from system.one where 0) where sum is null;
|
Loading…
Reference in New Issue
Block a user