Planner filter push down optimization fix

This commit is contained in:
Maksim Kita 2023-02-15 15:11:16 +01:00
parent 6b2adc1ec2
commit 4ddf1b0f48

View File

@ -333,8 +333,19 @@ size_t tryPushDownFilter(QueryPlan::Node * parent_node, QueryPlan::Nodes & nodes
// { // {
// } // }
if (auto updated_steps = simplePushDownOverStep<SortingStep>(parent_node, nodes, child)) if (auto * sorting = typeid_cast<SortingStep *>(child.get()))
return updated_steps; {
const auto & sort_description = sorting->getSortDescription();
auto sort_description_it = std::find_if(sort_description.begin(), sort_description.end(), [&](auto & sort_column_description)
{
return sort_column_description.column_name == filter->getFilterColumnName();
});
bool can_remove_filter = sort_description_it == sort_description.end();
Names allowed_inputs = child->getOutputStream().header.getNames();
if (auto updated_steps = tryAddNewFilterStep(parent_node, nodes, allowed_inputs, can_remove_filter))
return updated_steps;
}
if (auto updated_steps = simplePushDownOverStep<CreateSetAndFilterOnTheFlyStep>(parent_node, nodes, child)) if (auto updated_steps = simplePushDownOverStep<CreateSetAndFilterOnTheFlyStep>(parent_node, nodes, child))
return updated_steps; return updated_steps;