mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 05:32:52 +00:00
495c6e03aa
* Replace all Context references with std::weak_ptr * Fix shared context captured by value * Fix build * Fix Context with named sessions * Fix copy context * Fix gcc build * Merge with master and fix build * Fix gcc-9 build
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <Interpreters/Context_fwd.h>
|
|
#include <Interpreters/DatabaseAndTableWithAlias.h>
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
|
#include <Parsers/ASTSelectQuery.h>
|
|
#include <Parsers/ASTSelectWithUnionQuery.h>
|
|
#include <Parsers/IAST.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
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 &);
|
|
|
|
bool rewriteSubquery(ASTSelectQuery & subquery, const Names & inner_columns);
|
|
};
|
|
|
|
using PredicateRewriteMatcher = OneTypeMatcher<PredicateRewriteVisitorData, PredicateRewriteVisitorData::needChild>;
|
|
using PredicateRewriteVisitor = InDepthNodeVisitor<PredicateRewriteMatcher, true>;
|
|
|
|
}
|