aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/ConvertStringsToEnumVisitor.h
blob: b1389f406547b7d1ec5362523e1fe3f163f8886d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <vector>
#include <unordered_map>
#include <unordered_set>

#include <Interpreters/InDepthNodeVisitor.h>
#include <Parsers/IAST_fwd.h>


namespace DB
{

class ASTFunction;

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 = {};
    };

    static bool needChildVisit(const ASTPtr & node, const ASTPtr &);
    static void visit(const ASTPtr & ast, Data & data);
    static void visit(const ASTFunction & func, Data & data);
};

using FindUsedFunctionsVisitor = FindUsedFunctionsMatcher::Visitor;

struct ConvertStringsToEnumMatcher
{
    struct Data
    {
        std::unordered_set<String> & used_functions;
    };

    static bool needChildVisit(const ASTPtr & node, const ASTPtr &);
    static void visit(ASTPtr & ast, Data & data);
    static void visit(ASTFunction & function_node, Data & data);
};

using ConvertStringsToEnumVisitor = InDepthNodeVisitor<ConvertStringsToEnumMatcher, true>;

}