1#include "duckdb/optimizer/filter_pullup.hpp"
2#include "duckdb/planner/operator/logical_comparison_join.hpp"
3#include "duckdb/planner/operator/logical_join.hpp"
4
5namespace duckdb {
6
7unique_ptr<LogicalOperator> FilterPullup::PullupFromLeft(unique_ptr<LogicalOperator> op) {
8 D_ASSERT(op->type == LogicalOperatorType::LOGICAL_COMPARISON_JOIN ||
9 op->type == LogicalOperatorType::LOGICAL_ASOF_JOIN || op->type == LogicalOperatorType::LOGICAL_ANY_JOIN ||
10 op->type == LogicalOperatorType::LOGICAL_EXCEPT || op->type == LogicalOperatorType::LOGICAL_DELIM_JOIN);
11
12 FilterPullup left_pullup(true, can_add_column);
13 FilterPullup right_pullup(false, can_add_column);
14
15 op->children[0] = left_pullup.Rewrite(op: std::move(op->children[0]));
16 op->children[1] = right_pullup.Rewrite(op: std::move(op->children[1]));
17
18 // check only for filters from the LHS
19 if (!left_pullup.filters_expr_pullup.empty() && right_pullup.filters_expr_pullup.empty()) {
20 return GeneratePullupFilter(child: std::move(op), expressions&: left_pullup.filters_expr_pullup);
21 }
22 return op;
23}
24
25} // namespace duckdb
26