mingmwang commented on code in PR #5322:
URL: https://github.com/apache/arrow-datafusion/pull/5322#discussion_r1116459658
##########
datafusion/physical-expr/src/rewrite.rs:
##########
@@ -113,6 +113,21 @@ pub trait TreeNodeRewritable: Clone {
Ok(new_node)
}
+ fn mutable_transform_up<F>(self, op: &mut F) -> Result<Self>
+ where
+ F: FnMut(Self) -> Result<Option<Self>>,
+ {
+ let after_op_children =
+ self.map_children(|node| node.mutable_transform_up(op))?;
+
+ let after_op_children_clone = after_op_children.clone();
+ let new_node = match op(after_op_children)? {
+ Some(value) => value,
+ None => after_op_children_clone,
+ };
+ Ok(new_node)
+ }
+
Review Comment:
I think you can leverage the `transform_using()` (Visitor pattern) to
achieve the same effects instead of adding another` mutable_transform()`
method.
I think the Visitor pattern is more straightforward and easy to understand
if we want to collect some infos and modify the plan/structs during the
traversal process.
--
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]