aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Analyzer/Passes/GroupingFunctionsResolvePass.h
blob: 070c8dd9389d7d82c12ffbe44582a31dccde9673 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <Analyzer/IQueryTreePass.h>

namespace DB
{

/** Resolve GROUPING functions in query node.
  * GROUPING function is replaced with specialized GROUPING function based on GROUP BY modifiers.
  * For ROLLUP, CUBE, GROUPING SETS specialized GROUPING function take special __grouping_set column as argument
  * and previous GROUPING function arguments.
  *
  * Example: SELECT grouping(id) FROM test_table GROUP BY id;
  * Result: SELECT groupingOrdinary(id) FROM test_table GROUP BY id;
  *
  * Example: SELECT grouping(id), grouping(value) FROM test_table GROUP BY GROUPING SETS ((id), (value));
  * Result: SELECT groupingForGroupingSets(__grouping_set, id), groupingForGroupingSets(__grouping_set, value)
  * FROM test_table GROUP BY GROUPING SETS ((id), (value));
  */
class GroupingFunctionsResolvePass final : public IQueryTreePass
{
public:
    String getName() override { return "GroupingFunctionsResolvePass"; }

    String getDescription() override { return "Resolve GROUPING functions based on GROUP BY modifiers"; }

    void run(QueryTreeNodePtr query_tree_node, ContextPtr context) override;

};

}