1#include "duckdb/optimizer/filter_pullup.hpp"
2
3namespace duckdb {
4
5unique_ptr<LogicalOperator> FilterPullup::PullupBothSide(unique_ptr<LogicalOperator> op) {
6 FilterPullup left_pullup(true, can_add_column);
7 FilterPullup right_pullup(true, can_add_column);
8 op->children[0] = left_pullup.Rewrite(op: std::move(op->children[0]));
9 op->children[1] = right_pullup.Rewrite(op: std::move(op->children[1]));
10 D_ASSERT(left_pullup.can_add_column == can_add_column);
11 D_ASSERT(right_pullup.can_add_column == can_add_column);
12
13 // merging filter expressions
14 for (idx_t i = 0; i < right_pullup.filters_expr_pullup.size(); ++i) {
15 left_pullup.filters_expr_pullup.push_back(x: std::move(right_pullup.filters_expr_pullup[i]));
16 }
17
18 if (!left_pullup.filters_expr_pullup.empty()) {
19 return GeneratePullupFilter(child: std::move(op), expressions&: left_pullup.filters_expr_pullup);
20 }
21 return op;
22}
23
24} // namespace duckdb
25