MCPcopy Create free account
hub / github.com/apache/datafusion / add_filter

Function add_filter

datafusion/expr/src/utils.rs:1239–1252  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

1237/// plan
1238/// ```
1239pub 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)

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
andFunction · 0.70
FilterClass · 0.50
skipMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…