aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-11-14 09:58:56 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-11-14 10:20:20 +0300
commitc2b2dfd9827a400a8495e172a56343462e3ceb82 (patch)
treecd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h
parentd4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff)
downloadydb-c2b2dfd9827a400a8495e172a56343462e3ceb82.tar.gz
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h')
-rw-r--r--contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h b/contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h
new file mode 100644
index 0000000000..d2b9ece930
--- /dev/null
+++ b/contrib/clickhouse/src/Interpreters/PredicateRewriteVisitor.h
@@ -0,0 +1,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>;
+
+}