mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +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>
31 lines
725 B
C++
31 lines
725 B
C++
#pragma once
|
|
|
|
#include <Parsers/IAST.h>
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class ASTSelectQuery;
|
|
|
|
/// Rewrite GROUPING SETS with only one group, to GROUP BY.
|
|
///
|
|
/// Examples:
|
|
/// - GROUPING SETS (foo) -> GROUP BY foo
|
|
/// - GROUPING SETS ((foo, bar)) -> GROUP BY foo, bar
|
|
///
|
|
/// But not the following:
|
|
/// - GROUPING SETS (foo, bar) (since it has two groups (foo) and (bar))
|
|
class GroupingSetsRewriterData
|
|
{
|
|
public:
|
|
using TypeToVisit = ASTSelectQuery;
|
|
|
|
static void visit(ASTSelectQuery & select_query, ASTPtr &);
|
|
};
|
|
|
|
using GroupingSetsRewriterMatcher = OneTypeMatcher<GroupingSetsRewriterData>;
|
|
using GroupingSetsRewriterVisitor = InDepthNodeVisitor<GroupingSetsRewriterMatcher, true>;
|
|
|
|
}
|