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
rewrite_expr in datafusion_expr::expr_rewriter - Rust
[go: Go Back, main page]

pub fn rewrite_expr<F>(expr: Expr, f: F) -> Result<Expr>where
    F: FnMut(Expr) -> Result<Expr>,
Expand description

Recursively rewrite an Expr via a function.

Rewrites the expression bottom up by recursively calling f(expr) on expr’s children and then on expr. See ExprRewriter for more details and more options to control the walk.

Example:

let expr = col("a") + lit(1);

// rewrite all literals to 42
let rewritten = rewrite_expr(expr, |e| {
  if let Expr::Literal(_) = e {
    Ok(lit(42))
  } else {
    Ok(e)
  }
}).unwrap();

assert_eq!(rewritten, col("a") + lit(42));