#pragma once #include #include #include namespace DB { class ASTIdentifier; class ASTQualifiedAsterisk; struct ASTTableJoin; class ASTSelectQuery; /// Visit one node for names qualification. @sa InDepthNodeVisitor. class TranslateQualifiedNamesMatcher { public: struct Data { const NameSet & source_columns; const std::vector & tables; }; static constexpr const char * label = "TranslateQualifiedNames"; static std::vector visit(ASTPtr & ast, Data & data); static bool needChildVisit(ASTPtr & node, const ASTPtr & child); private: static std::vector visit(const ASTIdentifier & node, ASTPtr & ast, Data &); static std::vector visit(const ASTQualifiedAsterisk & node, const ASTPtr & ast, Data &); static std::vector visit(const ASTTableJoin & node, const ASTPtr & ast, Data &); static std::vector visit(const ASTSelectQuery & node, const ASTPtr & ast, Data &); }; /// Visits AST for names qualification. /// It finds columns (general identifiers and asterisks) and translate their names according to tables' names. using TranslateQualifiedNamesVisitor = InDepthNodeVisitor; }