From 7c90e70dc51af45e20d72a213b0d717cb6d8e75d Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Sun, 7 Apr 2024 12:11:00 -0400 Subject: [PATCH] Add deprecated LogicalPlan::inspect_expressions --- datafusion/expr/src/logical_plan/plan.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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.