geoffreyclaude commented on code in PR #26118:
URL: https://github.com/apache/datafusion/pull/26118#discussion_r4388681724
##########
datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/sort_pushdown.rs:
##########
@@ -1034,61 +1029,178 @@ fn handle_custom_pushdown(
return Ok(None);
};
- // Check if all required columns come from the order-maintaining child:
+ // Matching column positions is only a candidate; prove output ordering
below.
let start_idx = children_schema_lengths[..maintained_child_idx]
.iter()
.sum::<usize>();
let end_idx = start_idx + children_schema_lengths[maintained_child_idx];
- let all_from_maintained_child =
- all_indices.iter().all(|i| i >= &start_idx && i < &end_idx);
+ let fits_maintained_input = columns
+ .iter()
+ .all(|col| (start_idx..end_idx).contains(&col.index()));
- // If all columns are from the maintained child, update the parent
requirements:
- if all_from_maintained_child {
- let sub_offset = children_schema_lengths
+ let child_requirements = if fits_maintained_input {
Review Comment:
Much cleaner indeed! I applied this as a new commit. Thanks for the keen
eyes!
--
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]