diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 506c9266b3e0..4f55bbfe3f4d 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -284,6 +284,27 @@ impl LogicalPlan { exprs } + #[deprecated(since = "37.0.0", note = "Use `apply_expressions` instead")] + pub fn inspect_expressions(self: &LogicalPlan, mut f: F) -> Result<(), E> + where + F: FnMut(&Expr) -> Result<(), E>, + { + let mut err = Ok(()); + self.apply_expressions(|e| { + if let Err(e) = f(e) { + // save the error for later (it may not be a DataFusionError + err = Err(e); + Ok(TreeNodeRecursion::Stop) + } else { + Ok(TreeNodeRecursion::Continue) + } + }) + // The closure always returns OK, so this will always too + .expect("no way to return error during recursion"); + + err + } + /// Calls `f` on all expressions (non-recursively) in the current /// logical plan node. This does not include expressions in any /// children.