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

Function find_exprs_in_expr

datafusion/expr/src/utils.rs:695–714  ·  view source on GitHub ↗

Search an `Expr`, and all of its nested `Expr`'s, for any that pass the provided test. The returned `Expr`'s are deduplicated and returned in order of appearance (depth first).

(expr: &Expr, test_fn: &F)

Source from the content-addressed store, hash-verified

693/// provided test. The returned `Expr`'s are deduplicated and returned in order
694/// of appearance (depth first).
695fn find_exprs_in_expr<F>(expr: &Expr, test_fn: &F) -> Vec<Expr>
696where
697 F: Fn(&Expr) -> bool,
698{
699 let mut exprs = vec![];
700 expr.apply(|expr| {
701 if test_fn(expr) {
702 if !(exprs.contains(expr)) {
703 exprs.push(expr.clone())
704 }
705 // Stop recursing down this expr once we find a match
706 return Ok(TreeNodeRecursion::Jump);
707 }
708
709 Ok(TreeNodeRecursion::Continue)
710 })
711 // pre_visit always returns OK, so this will always too
712 .expect("no way to return error during recursion");
713 exprs
714}
715
716/// Recursively inspect an [`Expr`] and all its children.
717pub fn inspect_expr_pre<F, E>(expr: &Expr, mut f: F) -> Result<(), E>

Callers 2

find_out_reference_exprsFunction · 0.85
find_exprs_in_exprsFunction · 0.85

Calls 4

applyMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…