mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix pushdown of having
This commit is contained in:
parent
c5354885a6
commit
fa9a19cbdd
@ -38,7 +38,7 @@ static size_t tryAddNewFilterStep(
|
||||
|
||||
auto * filter = static_cast<FilterStep *>(parent.get());
|
||||
const auto & expression = filter->getExpression();
|
||||
const auto & filter_column_name = filter->getFilterColumnName();
|
||||
const auto filter_column_name = filter->getFilterColumnName();
|
||||
bool removes_filter = filter->removesFilterColumn();
|
||||
|
||||
// std::cerr << "Filter: \n" << expression->dumpDAG() << std::endl;
|
||||
@ -75,9 +75,10 @@ static size_t tryAddNewFilterStep(
|
||||
|
||||
/// New filter column is added to the end.
|
||||
auto split_filter_column_name = (*split_filter->getIndex().rbegin())->result_name;
|
||||
bool remove_split_filter_column = (split_filter_column_name != filter_column_name || removes_filter);
|
||||
node.step = std::make_unique<FilterStep>(
|
||||
node.children.at(0)->step->getOutputStream(),
|
||||
std::move(split_filter), std::move(split_filter_column_name), true);
|
||||
std::move(split_filter), std::move(split_filter_column_name), remove_split_filter_column);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
1 1 2
|
11
tests/queries/0_stateless/01798_having_push_down.sql
Normal file
11
tests/queries/0_stateless/01798_having_push_down.sql
Normal file
@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS t_having;
|
||||
|
||||
CREATE TABLE t_having (c0 Int32, c1 UInt64) ENGINE = Memory;
|
||||
|
||||
INSERT INTO t_having SELECT number, number FROM numbers(1000);
|
||||
|
||||
SELECT sum(c0 = 0), min(c0 + 1), sum(c0 + 2) FROM t_having
|
||||
GROUP BY c0 HAVING c0 = 0
|
||||
SETTINGS enable_optimize_predicate_expression=0;
|
||||
|
||||
DROP TABLE t_having;
|
Loading…
Reference in New Issue
Block a user