peter-toth opened a new pull request, #13467: URL: https://github.com/apache/datafusion/pull/13467
## Which issue does this PR close? Part of https://github.com/apache/datafusion/issues/8913. ## Rationale for this change The current implementation of `LogicalPlan:apply_children()`, `LogicalPlan::map_children()`, `LogicalPlan::apply_expressions()`, `LogicalPlan::map_expressions()`, `Expr::apply_children()` and `Expr::map_children()` are confusing due the `map_until_stop_and_collect` macro. I think we can introduce a trait that can contain sibling arbitrary elements that can be applied on and mapped: ``` /// [`Container`] contains elements that a function can be applied on or mapped. The /// elements of the container are siblings so the continuation rules are similar to /// [`TreeNodeRecursion::visit_sibling`] / [`Transformed::transform_sibling`]. pub trait Container<'a, T: 'a>: Sized { fn apply_elements<F: FnMut(&'a T) -> Result<TreeNodeRecursion>>( &'a self, f: F, ) -> Result<TreeNodeRecursion>; fn map_elements<F: FnMut(T) -> Result<Transformed<T>>>( self, f: F, ) -> Result<Transformed<Self>>; } ``` ## What changes are included in this PR? This PR: - Gets rid of `map_until_stop_and_collect` macro. - Adds the `Container` trait and blanket implementations for `Box`, `Option`, `Vec`, tuples, ... - Defined the `Container` implementation for `Expr` and `LogicalPlan`. - Simplifies the above mentioned `apply...` and `map...` methods. ## Are these changes tested? Yes, with exitsing UTs. ## Are there any user-facing changes? No. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org