2018-09-12 05:41:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-25 11:43:19 +00:00
|
|
|
#include <Interpreters/Aliases.h>
|
2018-12-06 19:02:42 +00:00
|
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
2018-09-12 05:41:09 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-11-02 15:09:15 +00:00
|
|
|
class ASTSelectWithUnionQuery;
|
|
|
|
class ASTSubquery;
|
|
|
|
struct ASTTableExpression;
|
|
|
|
struct ASTArrayJoin;
|
|
|
|
|
2018-12-06 19:02:42 +00:00
|
|
|
/// Visits AST node to collect aliases.
|
|
|
|
class QueryAliasesMatcher
|
2018-09-27 19:25:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-02-22 13:33:56 +00:00
|
|
|
using Visitor = InDepthNodeVisitor<QueryAliasesMatcher, false>;
|
|
|
|
|
2018-12-06 19:02:42 +00:00
|
|
|
struct Data
|
|
|
|
{
|
|
|
|
Aliases & aliases;
|
|
|
|
};
|
2018-09-27 19:25:18 +00:00
|
|
|
|
2019-02-22 13:33:56 +00:00
|
|
|
static void visit(ASTPtr & ast, Data & data);
|
2018-12-06 19:02:42 +00:00
|
|
|
static bool needChildVisit(ASTPtr & node, const ASTPtr & child);
|
2018-11-02 15:09:15 +00:00
|
|
|
|
2018-12-06 19:02:42 +00:00
|
|
|
private:
|
2019-02-22 13:33:56 +00:00
|
|
|
static void visit(ASTSubquery & subquery, const ASTPtr & ast, Data & data);
|
|
|
|
static void visit(const ASTArrayJoin &, const ASTPtr & ast, Data & data);
|
2018-12-06 19:02:42 +00:00
|
|
|
static void visitOther(const ASTPtr & ast, Data & data);
|
2018-09-27 19:25:18 +00:00
|
|
|
};
|
2018-09-12 05:41:09 +00:00
|
|
|
|
2018-12-06 19:02:42 +00:00
|
|
|
/// Visits AST nodes and collect their aliases in one map (with links to source nodes).
|
2019-02-22 13:33:56 +00:00
|
|
|
using QueryAliasesVisitor = QueryAliasesMatcher::Visitor;
|
2018-12-06 19:02:42 +00:00
|
|
|
|
2018-09-12 05:41:09 +00:00
|
|
|
}
|