1#include "duckdb/optimizer/filter_pushdown.hpp"
2#include "duckdb/planner/operator/logical_empty_result.hpp"
3#include "duckdb/planner/operator/logical_filter.hpp"
4
5using namespace duckdb;
6using namespace std;
7
8using Filter = FilterPushdown::Filter;
9
10unique_ptr<LogicalOperator> FilterPushdown::PushdownFilter(unique_ptr<LogicalOperator> op) {
11 assert(op->type == LogicalOperatorType::FILTER);
12 auto &filter = (LogicalFilter &)*op;
13 // filter: gather the filters and remove the filter from the set of operations
14 for (idx_t i = 0; i < filter.expressions.size(); i++) {
15 if (AddFilter(move(filter.expressions[i])) == FilterResult::UNSATISFIABLE) {
16 // filter statically evaluates to false, strip tree
17 return make_unique<LogicalEmptyResult>(move(op));
18 }
19 }
20 GenerateFilters();
21 return Rewrite(move(filter.children[0]));
22}
23