berkaysynnada opened a new issue, #9457: URL: https://github.com/apache/arrow-datafusion/issues/9457
### Is your feature request related to a problem or challenge? The recent update in #8891 has made significant improvements, making many `TreeNode` implementations simpler and more straightforward. However, the [map_children](https://github.com/apache/arrow-datafusion/blob/ac27428788cec96752a41eccb620956f7184047d/datafusion/expr/src/tree_node/expr.rs#L143) method in `Expr` enum appears to be quite complex. I think there's room for improvement in making this design more user-friendly, which would not only enhance user comprehension, but also help debugging. Take, for instance, the `Expr::Case` pattern: ``` Expr::Case(Case { expr, when_then_expr, else_expr, }) => transform_option_box(expr, &mut f)? .update_data(|new_expr| (new_expr, when_then_expr, else_expr)) .try_transform_node(|(new_expr, when_then_expr, else_expr)| { Ok(when_then_expr .into_iter() .map_until_stop_and_collect(|(when, then)| { transform_box(when, &mut f)? .update_data(|new_when| (new_when, then)) .try_transform_node(|(new_when, then)| { Ok(transform_box(then, &mut f)? .update_data(|new_then| (new_when, new_then))) }) })? .update_data(|new_when_then_expr| { (new_expr, new_when_then_expr, else_expr) })) })? .try_transform_node(|(new_expr, new_when_then_expr, else_expr)| { Ok(transform_option_box(else_expr, &mut f)?.update_data( |new_else_expr| (new_expr, new_when_then_expr, new_else_expr), )) })? .update_data(|(new_expr, new_when_then_expr, new_else_expr)| { Expr::Case(Case::new(new_expr, new_when_then_expr, new_else_expr)) }), ``` As shown, the function employs multiple nested and chained utility functions, which can be quite daunting. Simplifying these would significantly enhance readability and understanding. ### Describe the solution you'd like New implementations of `TreeNode` for `Option` and `Box` may be implemented, or new simplifying utils may be written with a more understandable style. ### Describe alternatives you've considered _No response_ ### Additional context _No response_ -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
