aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/RewriteOrderByVisitor.hpp
blob: a3857e046cad7a6fe06777857fdf7935f215e7dd (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
32
33
34
35
#pragma once

#include <Parsers/IAST.h>
#include <Interpreters/InDepthNodeVisitor.h>

namespace DB
{
///
/// Remove outer braces in ORDER BY
/// For example, rewrite (1) to (2)
/// (1) ... ORDER BY (a, b)
/// │    ExpressionList (children 1)              │
/// │     OrderByElement (children 1)             │
/// │      Function tuple (children 1)            │
/// │       ExpressionList (children 2)           │
/// │        Identifier CounterID                 │
/// │        Identifier EventDate                 │
/// (2) ... ORDER BY a,b
/// │    ExpressionList (children 2)              │
/// │     OrderByElement (children 1)             │
/// │      Identifier CounterID                   │
/// │     OrderByElement (children 1)             │
/// │      Identifier EventDate                   │
///
class RewriteOrderBy
{
public:
    struct Data {};
    static void visit(ASTPtr & ast, Data &);
    static bool needChildVisit(const ASTPtr &, const ASTPtr &) { return true; }
};

using RewriteOrderByVisitor = InDepthNodeVisitor<RewriteOrderBy, true>;
}