Rewrites all expressions in the current `LogicalPlan` node using `f`. Returns the current node. # Notes Similar to [`TreeNode::map_children`] but for this node's expressions. Visits only the top level expressions (Does not recurse into each expression)
(
self,
mut f: F,
)
| 487 | /// * Similar to [`TreeNode::map_children`] but for this node's expressions. |
| 488 | /// * Visits only the top level expressions (Does not recurse into each expression) |
| 489 | pub fn map_expressions<F: FnMut(Expr) -> Result<Transformed<Expr>>>( |
| 490 | self, |
| 491 | mut f: F, |
| 492 | ) -> Result<Transformed<Self>> { |
| 493 | Ok(match self { |
| 494 | LogicalPlan::Projection(Projection { |
| 495 | expr, |
| 496 | input, |
| 497 | schema, |
| 498 | }) => expr.map_elements(f)?.update_data(|expr| { |
| 499 | LogicalPlan::Projection(Projection { |
| 500 | expr, |
| 501 | input, |
| 502 | schema, |
| 503 | }) |
| 504 | }), |
| 505 | LogicalPlan::Values(Values { schema, values }) => values |
| 506 | .map_elements(f)? |
| 507 | .update_data(|values| LogicalPlan::Values(Values { schema, values })), |
| 508 | LogicalPlan::Filter(Filter { predicate, input }) => f(predicate)? |
| 509 | .update_data(|predicate| { |
| 510 | LogicalPlan::Filter(Filter { predicate, input }) |
| 511 | }), |
| 512 | LogicalPlan::Repartition(Repartition { |
| 513 | input, |
| 514 | partitioning_scheme, |
| 515 | }) => match partitioning_scheme { |
| 516 | Partitioning::Hash(expr, usize) => expr |
| 517 | .map_elements(f)? |
| 518 | .update_data(|expr| Partitioning::Hash(expr, usize)), |
| 519 | Partitioning::DistributeBy(expr) => expr |
| 520 | .map_elements(f)? |
| 521 | .update_data(Partitioning::DistributeBy), |
| 522 | Partitioning::RoundRobinBatch(_) => Transformed::no(partitioning_scheme), |
| 523 | } |
| 524 | .update_data(|partitioning_scheme| { |
| 525 | LogicalPlan::Repartition(Repartition { |
| 526 | input, |
| 527 | partitioning_scheme, |
| 528 | }) |
| 529 | }), |
| 530 | LogicalPlan::Window(Window { |
| 531 | input, |
| 532 | window_expr, |
| 533 | schema, |
| 534 | }) => window_expr.map_elements(f)?.update_data(|window_expr| { |
| 535 | LogicalPlan::Window(Window { |
| 536 | input, |
| 537 | window_expr, |
| 538 | schema, |
| 539 | }) |
| 540 | }), |
| 541 | LogicalPlan::Aggregate(Aggregate { |
| 542 | input, |
| 543 | group_expr, |
| 544 | aggr_expr, |
| 545 | schema, |
| 546 | }) => (group_expr, aggr_expr).map_elements(f)?.update_data( |