aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Analyzer/QueryTreePassManager.h
blob: 3c67fc361785199d7437a6548ccf5dea6a89ab6d (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
49
#pragma once

#include <Analyzer/IQueryTreePass.h>

#include <Interpreters/Context_fwd.h>

namespace DB
{

/** Query tree pass manager provide functionality to register and run passes
  * on query tree.
  */
class QueryTreePassManager : public WithContext
{
public:
    explicit QueryTreePassManager(ContextPtr context_);

    /// Get registered passes
    const std::vector<QueryTreePassPtr> & getPasses() const
    {
        return passes;
    }

    /// Add query tree pass
    void addPass(QueryTreePassPtr pass);

    /// Run query tree passes on query tree
    void run(QueryTreeNodePtr query_tree_node);

    /** Run query tree passes on query tree up to up_to_pass_index.
      * Throws exception if up_to_pass_index is greater than passes size.
      */
    void run(QueryTreeNodePtr query_tree_node, size_t up_to_pass_index);

    /// Dump query tree passes
    void dump(WriteBuffer & buffer);

    /** Dump query tree passes to up_to_pass_index.
      * Throws exception if up_to_pass_index is greater than passes size.
      */
    void dump(WriteBuffer & buffer, size_t up_to_pass_index);

private:
    std::vector<QueryTreePassPtr> passes;
};

void addQueryTreePasses(QueryTreePassManager & manager);

}