1 | #pragma once |
2 | |
3 | #include <Interpreters/Aliases.h> |
4 | #include <Interpreters/InDepthNodeVisitor.h> |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | class ASTSelectQuery; |
10 | class ASTSubquery; |
11 | struct ASTTableExpression; |
12 | struct ASTArrayJoin; |
13 | |
14 | /// Visits AST node to collect aliases. |
15 | class QueryAliasesMatcher |
16 | { |
17 | public: |
18 | using Visitor = InDepthNodeVisitor<QueryAliasesMatcher, false>; |
19 | |
20 | struct Data |
21 | { |
22 | Aliases & aliases; |
23 | }; |
24 | |
25 | static void visit(ASTPtr & ast, Data & data); |
26 | static bool needChildVisit(ASTPtr & node, const ASTPtr & child); |
27 | |
28 | private: |
29 | static void visit(const ASTSelectQuery & select, const ASTPtr & ast, Data & data); |
30 | static void visit(ASTSubquery & subquery, const ASTPtr & ast, Data & data); |
31 | static void visit(const ASTArrayJoin &, const ASTPtr & ast, Data & data); |
32 | static void visitOther(const ASTPtr & ast, Data & data); |
33 | }; |
34 | |
35 | /// Visits AST nodes and collect their aliases in one map (with links to source nodes). |
36 | using QueryAliasesVisitor = QueryAliasesMatcher::Visitor; |
37 | |
38 | } |
39 | |