Trait datafusion_expr::PlanVisitor
source · [−]pub trait PlanVisitor {
type Error;
fn pre_visit(&mut self, plan: &LogicalPlan) -> Result<bool, Self::Error>;
fn post_visit(&mut self, _plan: &LogicalPlan) -> Result<bool, Self::Error> { ... }
}
Expand description
Trait that implements the Visitor
pattern for a
depth first walk of LogicalPlan
nodes. pre_visit
is called
before any children are visited, and then post_visit
is called
after all children have been visited.
To use, define a struct that implements this trait and then invoke
LogicalPlan::accept
.
For example, for a logical plan like:
Projection: #id
Filter: #state Eq Utf8(\"CO\")\
CsvScan: employee.csv projection=Some([0, 3])";
The sequence of visit operations would be:
visitor.pre_visit(Projection)
visitor.pre_visit(Filter)
visitor.pre_visit(CsvScan)
visitor.post_visit(CsvScan)
visitor.post_visit(Filter)
visitor.post_visit(Projection)
Required Associated Types
Required Methods
Invoked on a logical plan before any of its child inputs have been
visited. If Ok(true) is returned, the recursion continues. If
Err(..) or Ok(false) are returned, the recursion stops
immediately and the error, if any, is returned to accept
Provided Methods
fn post_visit(&mut self, _plan: &LogicalPlan) -> Result<bool, Self::Error>
fn post_visit(&mut self, _plan: &LogicalPlan) -> Result<bool, Self::Error>
Invoked on a logical plan after all of its child inputs have
been visited. The return value is handled the same as the
return value of pre_visit
. The provided default implementation
returns Ok(true)
.