MCPcopy Create free account
hub / github.com/apache/datafusion / map_expressions

Method map_expressions

datafusion/expr/src/logical_plan/tree_node.rs:489–674  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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(

Callers 10

rewriteMethod · 0.80
map_subqueriesMethod · 0.80
extract_from_planFunction · 0.80
rewrite_planMethod · 0.80
rewrite_planMethod · 0.80
analyze_internalFunction · 0.80
optimize_internalMethod · 0.80

Calls 15

ProjectionClass · 0.85
ValuesClass · 0.85
RepartitionClass · 0.85
WindowClass · 0.85
AggregateClass · 0.85
JoinClass · 0.85
ExtensionClass · 0.85
newFunction · 0.85
TableScanClass · 0.85
DistinctEnum · 0.85
LimitClass · 0.85
ExecuteClass · 0.85

Tested by 1