zhuqi-lucas opened a new pull request, #21947:
URL: https://github.com/apache/datafusion/pull/21947

   ## Which issue does this PR close?
   
   Closes #21946
   
   ## Rationale for this change
   
   `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.
   
   ## What changes are included in this PR?
   
   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.
   
   ## Are these changes tested?
   
   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`
   
   ## Are there any user-facing changes?
   
   No. This is a performance optimization that does not change query results or 
plan structure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to