aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/GroupingSetsRewriterVisitor.cpp
blob: e5b930376cda3626d7e4ea7e459e566f7b846ca7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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;
}

}