2020-07-17 09:28:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-05-08 16:09:17 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
2020-07-17 09:28:51 +00:00
|
|
|
|
2021-05-08 16:09:17 +00:00
|
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
|
|
|
#include <Parsers/IAST_fwd.h>
|
2020-07-17 09:28:51 +00:00
|
|
|
|
|
|
|
|
2021-05-08 16:09:17 +00:00
|
|
|
namespace DB
|
2020-07-17 09:28:51 +00:00
|
|
|
{
|
|
|
|
|
2021-05-08 16:09:17 +00:00
|
|
|
class ASTFunction;
|
2020-07-17 09:28:51 +00:00
|
|
|
|
|
|
|
struct FindUsedFunctionsMatcher
|
|
|
|
{
|
|
|
|
using Visitor = ConstInDepthNodeVisitor<FindUsedFunctionsMatcher, true>;
|
|
|
|
|
|
|
|
struct Data
|
|
|
|
{
|
|
|
|
const std::unordered_set<String> & names;
|
|
|
|
std::unordered_set<String> & used_functions;
|
|
|
|
std::vector<String> call_stack = {};
|
|
|
|
};
|
|
|
|
|
2021-05-08 16:09:17 +00:00
|
|
|
static bool needChildVisit(const ASTPtr & node, const ASTPtr &);
|
|
|
|
static void visit(const ASTPtr & ast, Data & data);
|
|
|
|
static void visit(const ASTFunction & func, Data & data);
|
2020-07-17 09:28:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using FindUsedFunctionsVisitor = FindUsedFunctionsMatcher::Visitor;
|
|
|
|
|
|
|
|
struct ConvertStringsToEnumMatcher
|
|
|
|
{
|
|
|
|
struct Data
|
|
|
|
{
|
|
|
|
std::unordered_set<String> & used_functions;
|
|
|
|
};
|
|
|
|
|
2021-05-08 16:09:17 +00:00
|
|
|
static bool needChildVisit(const ASTPtr & node, const ASTPtr &);
|
|
|
|
static void visit(ASTPtr & ast, Data & data);
|
|
|
|
static void visit(ASTFunction & function_node, Data & data);
|
2020-07-17 09:28:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using ConvertStringsToEnumVisitor = InDepthNodeVisitor<ConvertStringsToEnumMatcher, true>;
|
|
|
|
|
|
|
|
}
|