2019-02-20 12:12:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include <Parsers/ASTAsterisk.h>
|
|
|
|
#include <Parsers/ASTQualifiedAsterisk.h>
|
2019-07-21 17:03:58 +00:00
|
|
|
#include <Parsers/ASTColumnsMatcher.h>
|
2019-02-20 12:12:36 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
struct AsteriskSemanticImpl
|
|
|
|
{
|
|
|
|
using RevertedAliases = std::unordered_map<String, std::vector<String>>;
|
|
|
|
using RevertedAliasesPtr = std::shared_ptr<RevertedAliases>;
|
|
|
|
|
|
|
|
RevertedAliasesPtr aliases; /// map of aliases that should be set in phase of * expanding.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct AsteriskSemantic
|
|
|
|
{
|
|
|
|
using RevertedAliases = AsteriskSemanticImpl::RevertedAliases;
|
|
|
|
using RevertedAliasesPtr = AsteriskSemanticImpl::RevertedAliasesPtr;
|
|
|
|
|
|
|
|
static void setAliases(ASTAsterisk & node, const RevertedAliasesPtr & aliases) { node.semantic = makeSemantic(aliases); }
|
|
|
|
static void setAliases(ASTQualifiedAsterisk & node, const RevertedAliasesPtr & aliases) { node.semantic = makeSemantic(aliases); }
|
2019-07-21 17:03:58 +00:00
|
|
|
static void setAliases(ASTColumnsMatcher & node, const RevertedAliasesPtr & aliases) { node.semantic = makeSemantic(aliases); }
|
2019-02-20 12:12:36 +00:00
|
|
|
|
|
|
|
static RevertedAliasesPtr getAliases(const ASTAsterisk & node) { return node.semantic ? node.semantic->aliases : nullptr; }
|
|
|
|
static RevertedAliasesPtr getAliases(const ASTQualifiedAsterisk & node) { return node.semantic ? node.semantic->aliases : nullptr; }
|
2019-07-21 17:03:58 +00:00
|
|
|
static RevertedAliasesPtr getAliases(const ASTColumnsMatcher & node) { return node.semantic ? node.semantic->aliases : nullptr; }
|
2019-02-20 12:12:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static std::shared_ptr<AsteriskSemanticImpl> makeSemantic(const RevertedAliasesPtr & aliases)
|
|
|
|
{
|
|
|
|
return std::make_shared<AsteriskSemanticImpl>(AsteriskSemanticImpl{aliases});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|