mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 01:41:59 +00:00
1f29b0a901
This is better then introducing separate SelectQueryExpressionAnalyzer::useGroupingSetKey(), since for optimize_aggregation_in_order that method will not be enough, because size of ManyExpressionActions will not match size of SortDescription, in ReadInOrderOptimizer::ReadInOrderOptimizer() And plus it is cleaner. v2: fix clang-tidy Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
23 lines
585 B
C++
23 lines
585 B
C++
#include <Interpreters/GroupingSetsRewriterVisitor.h>
|
|
#include <Parsers/ASTSelectQuery.h>
|
|
#include <Parsers/ASTExpressionList.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
void GroupingSetsRewriterData::visit(ASTSelectQuery & select_query, ASTPtr &)
|
|
{
|
|
const ASTPtr group_by = select_query.groupBy();
|
|
if (!group_by || !select_query.group_by_with_grouping_sets)
|
|
return;
|
|
|
|
if (group_by->children.size() != 1)
|
|
return;
|
|
|
|
select_query.setExpression(ASTSelectQuery::Expression::GROUP_BY, std::move(group_by->children.front()));
|
|
select_query.group_by_with_grouping_sets = false;
|
|
}
|
|
|
|
}
|