From f4b47ca194c3f9838ae4d9529dd0fcb942db7ad2 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Mon, 13 Sep 2021 13:35:36 +0300 Subject: [PATCH] Don not add const group by key for query with only having. --- src/Interpreters/TreeOptimizer.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Interpreters/TreeOptimizer.cpp b/src/Interpreters/TreeOptimizer.cpp index 518c041d785..7c5df3fde4e 100644 --- a/src/Interpreters/TreeOptimizer.cpp +++ b/src/Interpreters/TreeOptimizer.cpp @@ -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 {