Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
ExprRewriter in datafusion_expr::expr_rewriter - Rust
[go: Go Back, main page]

pub trait ExprRewriter<E: ExprRewritable = Expr>: Sized {
    // Required method
    fn mutate(&mut self, expr: E) -> Result<E>;

    // Provided method
    fn pre_visit(&mut self, _expr: &E) -> Result<RewriteRecursion> { ... }
}
Expand description

Trait for potentially recursively rewriting an Expr expression tree. When passed to Expr::rewrite, ExpressionVisitor::mutate is invoked recursively on all nodes of an expression tree.

Performs a depth first walk of an expression and its children to rewrite an expression, consuming self producing a new Expr.

Implements a modified version of the visitor pattern to separate algorithms from the structure of the Expr tree and make it easier to write new, efficient expression transformation algorithms.

For an expression tree such as

BinaryExpr (GT)
   left: Column("foo")
   right: Column("bar")

The nodes are visited using the following order

pre_visit(BinaryExpr(GT))
pre_visit(Column("foo"))
mutate(Column("foo"))
pre_visit(Column("bar"))
mutate(Column("bar"))
mutate(BinaryExpr(GT))

If an Err result is returned, recursion is stopped immediately

If false is returned on a call to pre_visit, no children of that expression are visited, nor is mutate called on that expression

See Also:

  • [Expr::accept] to drive a rewriter through an Expr
  • rewrite_expr: For rewriting an Expr using functions

Required Methods§

source

fn mutate(&mut self, expr: E) -> Result<E>

Invoked after all children of expr have been mutated and returns a potentially modified expr.

Provided Methods§

source

fn pre_visit(&mut self, _expr: &E) -> Result<RewriteRecursion>

Invoked before any children of expr are rewritten / visited. Default implementation returns Ok(RewriteRecursion::Continue)

Implementors§