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
50
51
52
53
54
55
|
#pragma once
#include <Interpreters/Context_fwd.h>
#include <Interpreters/DatabaseAndTableWithAlias.h>
#include <Interpreters/InDepthNodeVisitor.h>
#include <Parsers/IAST_fwd.h>
namespace DB
{
class ASTSelectIntersectExceptQuery;
class ASTSelectQuery;
class ASTSelectWithUnionQuery;
class PredicateRewriteVisitorData : WithContext
{
public:
bool is_rewrite = false;
using TypeToVisit = ASTSelectWithUnionQuery;
void visit(ASTSelectWithUnionQuery & union_select_query, ASTPtr &);
static bool needChild(const ASTPtr & node, const ASTPtr &)
{
return !(node && node->as<TypeToVisit>());
}
PredicateRewriteVisitorData(
ContextPtr context_,
const ASTs & predicates_,
const TableWithColumnNamesAndTypes & table_columns_,
bool optimize_final_,
bool optimize_with_);
private:
const ASTs & predicates;
const TableWithColumnNamesAndTypes & table_columns;
bool optimize_final;
bool optimize_with;
void visitFirstInternalSelect(ASTSelectQuery & select_query, ASTPtr &);
void visitOtherInternalSelect(ASTSelectQuery & select_query, ASTPtr &);
void visit(ASTSelectIntersectExceptQuery & intersect_except_query, ASTPtr &);
bool rewriteSubquery(ASTSelectQuery & subquery, const Names & inner_columns);
void visitInternalSelect(size_t index, ASTSelectQuery & select_node, ASTPtr & node);
};
using PredicateRewriteMatcher = OneTypeMatcher<PredicateRewriteVisitorData, PredicateRewriteVisitorData::needChild>;
using PredicateRewriteVisitor = InDepthNodeVisitor<PredicateRewriteMatcher, true>;
}
|