Trait datafusion::common::tree_node::TreeNodeRewriter
source · pub trait TreeNodeRewriter: Sized {
type Node: TreeNode;
// Provided methods
fn f_down(
&mut self,
node: Self::Node,
) -> Result<Transformed<Self::Node>, DataFusionError> { ... }
fn f_up(
&mut self,
node: Self::Node,
) -> Result<Transformed<Self::Node>, DataFusionError> { ... }
}
Expand description
A Visitor for recursively
rewriting TreeNode
s via TreeNode::rewrite
.
For example you can implement this trait on a struct to rewrite Expr
or
LogicalPlan
that needs to track state during the rewrite.
See TreeNode
for more details on available APIs
When passed to TreeNode::rewrite
, TreeNodeRewriter::f_down
and
TreeNodeRewriter::f_up
are invoked recursively on the tree.
See TreeNodeRecursion
for more details on controlling the traversal.
§Return Value
The returns value of f_up
and f_down
specifies how the tree walk should
proceed. See TreeNodeRecursion
for details. If an Err
is returned,
the recursion stops immediately.
Note: If using the default implementations of TreeNodeRewriter::f_up
or
TreeNodeRewriter::f_down
that do nothing, consider using
TreeNode::transform_up
or TreeNode::transform_down
instead.
§See Also:
TreeNode::visit
to inspect borrowedTreeNode
s
Required Associated Types§
Provided Methods§
sourcefn f_down(
&mut self,
node: Self::Node,
) -> Result<Transformed<Self::Node>, DataFusionError>
fn f_down( &mut self, node: Self::Node, ) -> Result<Transformed<Self::Node>, DataFusionError>
Invoked while traversing down the tree before any children are rewritten. Default implementation returns the node as is and continues recursion.
sourcefn f_up(
&mut self,
node: Self::Node,
) -> Result<Transformed<Self::Node>, DataFusionError>
fn f_up( &mut self, node: Self::Node, ) -> Result<Transformed<Self::Node>, DataFusionError>
Invoked while traversing up the tree after all children have been rewritten. Default implementation returns the node as is and continues recursion.