Repository navigation
Commit 2e83c93
Skip unnecessary plan rebuild in adjust_input_keys_ordering for non-join plans (apache#21947)
Closes apache#21946
`adjust_input_keys_ordering` returns `Transformed::yes` unconditionally
in the default else branch, even when `requirements.data` is empty and
no changes were made. This triggers unnecessary `with_new_children`
rebuilds on every node in the plan tree for non-join/non-aggregate
queries.
For plans with custom `ExecutionPlan` nodes whose `with_new_children` is
expensive (e.g. nodes that re-evaluate cost functions on rebuild), this
causes significant overhead.
Add an early return with `Transformed::no` when
`requirements.data.is_empty()` in the default else branch of
`adjust_input_keys_ordering`. This skips the unnecessary plan tree
rebuild for simple scan/filter/limit plans that have no join key
reordering requirements.
Yes, two unit tests added:
- `adjust_input_keys_ordering_no_transform_for_scan` — verifies a bare
parquet scan returns `Transformed::no`
- `adjust_input_keys_ordering_no_transform_for_filter_scan` — verifies a
filter→scan tree returns `Transformed::no` via `transform_down`
No. This is a performance optimization that does not change query
results or plan structure.
(cherry picked from commit 05a6c45)1 parent f069fa6 commit 2e83c93
2 files changed
Lines changed: 33 additions & 0 deletions
File tree
- datafusion
- core/tests/physical_optimizer
- physical-optimizer/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3665 | 3665 | | |
3666 | 3666 | | |
3667 | 3667 | | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
| |||
0 commit comments