apache / apache/datafusion

Implement ExecutionPlan::map_expressions

Open
#20,899 7 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

`ExecutionPlan::apply_expressions` (#20337) added a read-only visitor API for physical expressions. To complete the API that mirrors `LogicalPlan::map_expressions `— we should also implement a write counterpart that allows transforming expressions and reconstructing the node.

Use cases:

- Part of https://github.com/apache/datafusion/issues/14342
- Any transformation that needs to replace expressions across a plan tree

### Describe the solution you'd like

Proposed API:

```
fn map_expressions(
self: Arc,
f: &mut F,
) -> Result>>
where
F: FnMut(Arc) -> Result>>;
```
Each ExecutionPlan implementor is responsible for transforming its expressions and reconstructing itself using direct struct construction, so that the PlanProperties (schema, ordering, partitioning) are reused without recomputation -- matching the behavior of `LogicalPlan::map_expressions`.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the ExecutionPlan::apply_expressions API, LogicalPlan::map_expressions, and the ExecutionPlan implementors. Review how each plan transforms expressions and reconstructs itself while reusing PlanProperties. Done means the proposed map_expressions API is available across the relevant implementors and preserves schema, ordering, and partitioning without recomputation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, data-engineering
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.