peter-toth commented on PR #8835:
URL: 
https://github.com/apache/arrow-datafusion/pull/8835#issuecomment-1895522505

   > And you are correct and the current interface may not be correct. How 
about changing the interface like this:
   > 
   > ```
   >     fn transform_up<F>(self, op: &F) -> Result<Transformed<Self>>
   >     where
   >         F: Fn(Self) -> Result<Transformed<Self>>
   > ```
   > 
   > Then we can leverage the `Transformed` to avoid use 
`with_new_children_if_necessary` in some cases.
   
   Yes, that's one of the options if we want to keep `Transformed`. But because 
`Transformed` is kind of a boolean flag and both `::Yes` and `::No` wraps a 
`TreeNode` we could just use `Result<(Self, bool)>`. In this case 
`transform_up()` would look like this:
   ```rust
       fn transform_up<F>(self, f: &F) -> Result<(Self, bool)>
       where
           F: Fn(Self) -> Result<(Self, bool)>,
       {
           self.map_children(|node| node.transform_up(f)).map(
               |node_with_new_children, children_transformed| {
                   f(node_with_new_children).map(
                       |(new_node_with_new_children, transformed)| {
                           (
                               new_node_with_new_children,
                               children_transformed || transformed,
                           )
                       },
                   )?
               },
           )
       }
   ```
   


-- 
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]

Reply via email to