Skip to content

Conversation

@alamb
Copy link

@alamb alamb commented Jan 15, 2026

This is a proposal for apache#19792 that avoids having to change most callsites of project_schema

askalt and others added 2 commits January 15, 2026 21:20
This patch aims to implement a fast-path for the ExecutionPlan::with_new_children function
for some plans, moving closer to a physical plan re-use implementation and improving planning
performance. If the passed children properties are the same as in self, we do not actually
recompute self's properties  (which could be costly if projection mapping is required).
Instead, we just replace the children and re-use self's properties as-is.

To be able to compare two different properties -- ExecutionPlan::properties(...) signature
is modified and now returns `&Arc<PlanProperties>`. If `children` properties are the same
in `with_new_children` -- we clone our properties arc and then a parent plan will consider
our properties as unchanged, doing the same.

Also, there are other improvements. The patch includes the following changes:

- Return `&Arc<PlanProperties>` from `ExecutionPlan::properties(...)` instead of a reference.
- Implement `with_new_children` fast-path if there is no children properties changes for all
  major plans.
- Store `Arc<[usize]>` instead of vector within `FilterExec`.
- Store `Arc<[usize]>` instead of vector within projection of `HashJoinExec`.
- Store `Arc<[Arc<AggregateFunctionExpr>]>` instead of vec for aggr expr and filters.
- Store `Arc<[ProjectionExpr]> instead of vec in `ProjectionExprs` struct.
- Get `Option<&[usize]>` instead of option vec ref in `project_schema` -- it makes API
  more flexible.

Note: currently, `reset_plan_states` does not allow to re-use plan in general: it is not
supported for dynamic filters and recursive queries features, as in this case state reset
should update pointers in the children plans.

Closes apache#19796
/// projecting to `vec![2, 1]` would return statistics for columns `{"c",
/// "b"}`.
pub fn project(mut self, projection: Option<&[usize]>) -> Self {
pub fn project(mut self, projection: Option<impl AsRef<[usize]>>) -> Self {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to make this function generic so the previous signature can mostly be used

@askalt askalt force-pushed the askalt/with_new_children_fast_path branch 3 times, most recently from fb13e41 to 509e3ff Compare January 16, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants