Calls `f` on all expressions in the current `LogicalPlan` node. # Notes Similar to [`TreeNode::apply`] but for this node's expressions. Does not include expressions in input `LogicalPlan` nodes Visits only the top level expressions (Does not recurse into each expression)
(
&self,
mut f: F,
)
| 400 | /// * Does not include expressions in input `LogicalPlan` nodes |
| 401 | /// * Visits only the top level expressions (Does not recurse into each expression) |
| 402 | pub fn apply_expressions<F: FnMut(&Expr) -> Result<TreeNodeRecursion>>( |
| 403 | &self, |
| 404 | mut f: F, |
| 405 | ) -> Result<TreeNodeRecursion> { |
| 406 | match self { |
| 407 | LogicalPlan::Projection(Projection { expr, .. }) => expr.apply_elements(f), |
| 408 | LogicalPlan::Values(Values { values, .. }) => values.apply_elements(f), |
| 409 | LogicalPlan::Filter(Filter { predicate, .. }) => f(predicate), |
| 410 | LogicalPlan::Repartition(Repartition { |
| 411 | partitioning_scheme, |
| 412 | .. |
| 413 | }) => match partitioning_scheme { |
| 414 | Partitioning::Hash(expr, _) | Partitioning::DistributeBy(expr) => { |
| 415 | expr.apply_elements(f) |
| 416 | } |
| 417 | Partitioning::RoundRobinBatch(_) => Ok(TreeNodeRecursion::Continue), |
| 418 | }, |
| 419 | LogicalPlan::Window(Window { window_expr, .. }) => { |
| 420 | window_expr.apply_elements(f) |
| 421 | } |
| 422 | LogicalPlan::Aggregate(Aggregate { |
| 423 | group_expr, |
| 424 | aggr_expr, |
| 425 | .. |
| 426 | }) => (group_expr, aggr_expr).apply_ref_elements(f), |
| 427 | // There are two part of expression for join, equijoin(on) and non-equijoin(filter). |
| 428 | // 1. the first part is `on.len()` equijoin expressions, and the struct of each expr is `left-on = right-on`. |
| 429 | // 2. the second part is non-equijoin(filter). |
| 430 | LogicalPlan::Join(Join { on, filter, .. }) => { |
| 431 | (on, filter).apply_ref_elements(f) |
| 432 | } |
| 433 | LogicalPlan::Sort(Sort { expr, .. }) => expr.apply_elements(f), |
| 434 | LogicalPlan::Extension(extension) => { |
| 435 | // would be nice to avoid this copy -- maybe can |
| 436 | // update extension to just observer Exprs |
| 437 | extension.node.expressions().apply_elements(f) |
| 438 | } |
| 439 | LogicalPlan::TableScan(TableScan { filters, .. }) => { |
| 440 | filters.apply_elements(f) |
| 441 | } |
| 442 | LogicalPlan::Unnest(unnest) => { |
| 443 | let exprs = unnest |
| 444 | .exec_columns |
| 445 | .iter() |
| 446 | .cloned() |
| 447 | .map(Expr::Column) |
| 448 | .collect::<Vec<_>>(); |
| 449 | exprs.apply_elements(f) |
| 450 | } |
| 451 | LogicalPlan::Distinct(Distinct::On(DistinctOn { |
| 452 | on_expr, |
| 453 | select_expr, |
| 454 | sort_expr, |
| 455 | .. |
| 456 | })) => (on_expr, select_expr, sort_expr).apply_ref_elements(f), |
| 457 | LogicalPlan::Limit(Limit { skip, fetch, .. }) => { |
| 458 | (skip, fetch).apply_ref_elements(f) |
| 459 | } |
no test coverage detected