2018-10-16 19:00:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-04-14 14:43:09 +00:00
|
|
|
#include <Interpreters/RequiredSourceColumnsData.h>
|
2018-12-26 14:43:25 +00:00
|
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
2018-11-10 20:09:07 +00:00
|
|
|
|
2018-10-16 19:00:05 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-26 14:43:25 +00:00
|
|
|
class ASTIdentifier;
|
|
|
|
class ASTFunction;
|
|
|
|
class ASTSelectQuery;
|
|
|
|
struct ASTTablesInSelectQueryElement;
|
|
|
|
struct ASTArrayJoin;
|
|
|
|
struct ASTTableExpression;
|
|
|
|
|
2018-12-07 16:28:20 +00:00
|
|
|
class RequiredSourceColumnsMatcher
|
2018-10-16 19:00:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-08-09 14:50:04 +00:00
|
|
|
using Visitor = ConstInDepthNodeVisitor<RequiredSourceColumnsMatcher, false>;
|
2020-04-14 14:43:09 +00:00
|
|
|
using Data = RequiredSourceColumnsData;
|
2018-12-07 16:28:20 +00:00
|
|
|
|
2019-08-09 14:50:04 +00:00
|
|
|
static bool needChildVisit(const ASTPtr & node, const ASTPtr & child);
|
|
|
|
static void visit(const ASTPtr & ast, Data & data);
|
2018-10-16 19:00:05 +00:00
|
|
|
|
2020-06-16 16:32:32 +00:00
|
|
|
static std::vector<String> extractNamesFromLambda(const ASTFunction & node);
|
|
|
|
|
2018-10-16 19:00:05 +00:00
|
|
|
private:
|
2018-12-26 14:43:25 +00:00
|
|
|
static void visit(const ASTIdentifier & node, const ASTPtr &, Data & data);
|
|
|
|
static void visit(const ASTFunction & node, const ASTPtr &, Data & data);
|
2019-08-09 14:50:04 +00:00
|
|
|
static void visit(const ASTTablesInSelectQueryElement & node, const ASTPtr &, Data & data);
|
|
|
|
static void visit(const ASTTableExpression & node, const ASTPtr &, Data & data);
|
2019-02-22 13:33:56 +00:00
|
|
|
static void visit(const ASTArrayJoin & node, const ASTPtr &, Data & data);
|
2019-08-09 14:50:04 +00:00
|
|
|
static void visit(const ASTSelectQuery & select, const ASTPtr &, Data & data);
|
2018-10-16 19:00:05 +00:00
|
|
|
};
|
|
|
|
|
2020-04-14 14:43:09 +00:00
|
|
|
/// Extracts all the information about columns and tables from ASTSelectQuery block into Data object.
|
2018-12-26 20:35:06 +00:00
|
|
|
/// It doesn't use anything but AST. It visits nodes from bottom to top except ASTFunction content to get aliases in right manner.
|
2018-12-26 14:43:25 +00:00
|
|
|
/// @note There's some ambiguousness with nested columns names that can't be solved without schema.
|
2019-02-22 13:33:56 +00:00
|
|
|
using RequiredSourceColumnsVisitor = RequiredSourceColumnsMatcher::Visitor;
|
2018-12-07 16:28:20 +00:00
|
|
|
|
2018-10-16 19:00:05 +00:00
|
|
|
}
|