Returns a new [LogicalPlan] that filters the output of `plan` with a [LogicalPlan::Filter] with all `predicates` ANDed. # Example Before: ```text plan ``` After: ```text Filter(predicate) plan ```
(plan: LogicalPlan, predicates: &[&Expr])
| 1237 | /// plan |
| 1238 | /// ``` |
| 1239 | pub fn add_filter(plan: LogicalPlan, predicates: &[&Expr]) -> Result<LogicalPlan> { |
| 1240 | // reduce filters to a single filter with an AND |
| 1241 | let predicate = predicates |
| 1242 | .iter() |
| 1243 | .skip(1) |
| 1244 | .fold(predicates[0].clone(), |acc, predicate| { |
| 1245 | and(acc, (*predicate).to_owned()) |
| 1246 | }); |
| 1247 | |
| 1248 | Ok(LogicalPlan::Filter(Filter::try_new( |
| 1249 | predicate, |
| 1250 | Arc::new(plan), |
| 1251 | )?)) |
| 1252 | } |
| 1253 | |
| 1254 | /// Looks for correlating expressions: for example, a binary expression with one field from the subquery, and |
| 1255 | /// one not in the subquery (closed upon from outer scope) |