mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-15 20:24:07 +00:00
Fix constant result for prewhere optimization.
This commit is contained in:
parent
2b73641837
commit
ca237ee3c4
@ -152,10 +152,7 @@ addNewFilterStepOrThrow(QueryPlan::Node * parent_node, QueryPlan::Nodes & nodes,
|
||||
node.step = std::make_unique<FilterStep>(
|
||||
node.children.at(0)->step->getOutputHeader(), std::move(split_filter), std::move(split_filter_column_name), can_remove_filter);
|
||||
|
||||
if (auto * join = typeid_cast<JoinStep *>(child.get()))
|
||||
join->updateInputHeader(node.step->getOutputHeader(), child_idx);
|
||||
else
|
||||
child->updateInputHeader(node.step->getOutputHeader());
|
||||
child->updateInputHeader(node.step->getOutputHeader(), child_idx);
|
||||
|
||||
if (update_parent_filter)
|
||||
{
|
||||
|
@ -194,6 +194,22 @@ void optimizePrewhere(Stack & stack, QueryPlan::Nodes &)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!filter_step->removesFilterColumn())
|
||||
{
|
||||
const auto * node = split_result.second.tryFindInOutputs(filter_step->getFilterColumnName());
|
||||
if (node && !node->column)
|
||||
{
|
||||
ColumnWithTypeAndName column;
|
||||
column.type = node->result_type;
|
||||
column.name = node->result_name;
|
||||
column.column = column.type->createColumnConst(0, 1u);
|
||||
const auto * replaced_const = &split_result.second.addColumn(column);
|
||||
|
||||
for (auto & output : split_result.second.getOutputs())
|
||||
if (output == node)
|
||||
output = replaced_const;
|
||||
}
|
||||
}
|
||||
/// Have to keep this expression to change column names to column identifiers
|
||||
filter_node->step = std::make_unique<ExpressionStep>(
|
||||
source_step_with_filter->getOutputHeader(),
|
||||
|
Loading…
Reference in New Issue
Block a user