mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Fixes
This commit is contained in:
parent
bfde7fd36c
commit
6bc7fb1edf
@ -448,7 +448,7 @@ void QueryFuzzer::fuzz(ASTPtr & ast)
|
||||
{
|
||||
fuzz(with_union->list_of_selects);
|
||||
}
|
||||
if (auto * with_intersect_except = typeid_cast<ASTSelectIntersectExceptQuery *>(ast.get()))
|
||||
else if (auto * with_intersect_except = typeid_cast<ASTSelectIntersectExceptQuery *>(ast.get()))
|
||||
{
|
||||
auto selects = with_intersect_except->getListOfSelects();
|
||||
fuzz(selects);
|
||||
|
@ -73,8 +73,7 @@ void ApplyWithGlobalVisitor::visit(ASTPtr & ast)
|
||||
{
|
||||
if (ASTSelectWithUnionQuery * node_union = ast->as<ASTSelectWithUnionQuery>())
|
||||
{
|
||||
auto * first_select = typeid_cast<ASTSelectQuery *>(node_union->list_of_selects->children[0].get());
|
||||
if (first_select)
|
||||
if (auto * first_select = typeid_cast<ASTSelectQuery *>(node_union->list_of_selects->children[0].get()))
|
||||
{
|
||||
ASTPtr with_expression_list = first_select->with();
|
||||
if (with_expression_list)
|
||||
|
@ -41,18 +41,41 @@ void PredicateRewriteVisitorData::visit(ASTSelectWithUnionQuery & union_select_q
|
||||
{
|
||||
visit(*child_union, internal_select_list[index]);
|
||||
}
|
||||
else if (auto * child_intersect_except = internal_select_list[index]->as<ASTSelectIntersectExceptQuery>())
|
||||
{
|
||||
/// ASTSelectIntersectExceptQuery can have any depth and can contain
|
||||
/// select, union and insertsect_except nodes.
|
||||
/// TODO: add visitor?
|
||||
}
|
||||
else if (auto * child_select = internal_select_list[index]->as<ASTSelectQuery>())
|
||||
{
|
||||
if (index == 0)
|
||||
visitFirstInternalSelect(*child_select, internal_select_list[0]);
|
||||
else
|
||||
visitOtherInternalSelect(*child_select, internal_select_list[index]);
|
||||
visitInternalSelect(index, *child_select, internal_select_list[index]);
|
||||
}
|
||||
else if (auto * child_intersect_except = internal_select_list[index]->as<ASTSelectIntersectExceptQuery>())
|
||||
{
|
||||
visit(*child_intersect_except, internal_select_list[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PredicateRewriteVisitorData::visitInternalSelect(size_t index, ASTSelectQuery & select_node, ASTPtr & node)
|
||||
{
|
||||
if (index == 0)
|
||||
visitFirstInternalSelect(select_node, node);
|
||||
else
|
||||
visitOtherInternalSelect(select_node, node);
|
||||
}
|
||||
|
||||
void PredicateRewriteVisitorData::visit(ASTSelectIntersectExceptQuery & intersect_except_query, ASTPtr &)
|
||||
{
|
||||
auto internal_select_list = intersect_except_query.getListOfSelects();
|
||||
for (size_t index = 0; index < internal_select_list.size(); ++index)
|
||||
{
|
||||
if (auto * union_node = internal_select_list[index]->as<ASTSelectWithUnionQuery>())
|
||||
{
|
||||
visit(*union_node, internal_select_list[index]);
|
||||
}
|
||||
else if (auto * select_node = internal_select_list[index]->as<ASTSelectQuery>())
|
||||
{
|
||||
visitInternalSelect(index, *select_node, internal_select_list[index]);
|
||||
}
|
||||
else if (auto * intersect_node = internal_select_list[index]->as<ASTSelectIntersectExceptQuery>())
|
||||
{
|
||||
visit(*intersect_node, internal_select_list[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class ASTSelectIntersectExceptQuery;
|
||||
|
||||
class PredicateRewriteVisitorData : WithContext
|
||||
{
|
||||
public:
|
||||
@ -40,7 +42,11 @@ private:
|
||||
|
||||
void visitOtherInternalSelect(ASTSelectQuery & select_query, ASTPtr &);
|
||||
|
||||
void visit(ASTSelectIntersectExceptQuery & intersect_query, ASTPtr &);
|
||||
|
||||
bool rewriteSubquery(ASTSelectQuery & subquery, const Names & inner_columns);
|
||||
|
||||
void visitInternalSelect(size_t index, ASTSelectQuery & select_query, ASTPtr & node);
|
||||
};
|
||||
|
||||
using PredicateRewriteMatcher = OneTypeMatcher<PredicateRewriteVisitorData, PredicateRewriteVisitorData::needChild>;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Parsers/ASTQueryWithOutput.h>
|
||||
#include <Parsers/ASTSelectQuery.h>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user