Skip to content

Commit 81bc3cc

Browse files
adriangbalamb
andauthored
Apply suggestions from code review
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
1 parent 646d2af commit 81bc3cc

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

datafusion/optimizer/src/optimizer.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,8 @@ fn map_children_mut<F: FnMut(&mut LogicalPlan) -> Result<bool>>(
490490
/// # Error semantics
491491
///
492492
/// On `Err`, `*plan` is left in an **unspecified** state and must not be used.
493-
/// Because `rule.rewrite()` consumes the plan by value, a failing rule drops
494-
/// the node it was handed and the [`std::mem::take`] placeholder
495-
/// (`LogicalPlan::default()`, an `EmptyRelation`) is left in its place — at the
496-
/// root for a top-level failure, or somewhere in a subtree for a failure deeper
497-
/// in the recursion. The pre-rule plan is **not** recoverable here: restoring it
498-
/// would require cloning it before every rule invocation, which is exactly the
499-
/// allocation this function exists to avoid.
500-
///
501-
/// Callers must therefore discard `*plan` on `Err`, or restore it from a copy
502-
/// saved beforehand. [`Optimizer::optimize`] does this: with `skip_failed_rules`
503-
/// it restores `new_plan` from the `prev_plan` clone it already holds, and
504-
/// without it the error aborts the pass and the plan is dropped unobserved.
493+
/// Note this is different than consuming APIs such as [`TreeNode::rewrite`]
494+
/// where the original plan is freed and no longer available on error
505495
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
506496
fn rewrite_plan_in_place(
507497
plan: &mut LogicalPlan,

0 commit comments

Comments
 (0)