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

Method apply_expressions

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

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

Source from the content-addressed store, hash-verified

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 }

Callers 10

expressionsMethod · 0.80
all_out_ref_exprsMethod · 0.80
get_parameter_namesMethod · 0.80
get_parameter_fieldsMethod · 0.80
apply_subqueriesMethod · 0.80
with_plan_exprsMethod · 0.80

Calls 6

apply_ref_elementsMethod · 0.80
apply_elementsMethod · 0.45
expressionsMethod · 0.45
mapMethod · 0.45
clonedMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected