| 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 | |
| 5 | using namespace duckdb; |
| 6 | using namespace std; |
| 7 | |
| 8 | using Filter = FilterPushdown::Filter; |
| 9 | |
| 10 | unique_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 |