XiaoMingFa opened a new pull request, #26675:
URL: https://github.com/apache/datafusion/pull/26675

   ## Which issue does this PR close?
   
   - Closes #26626.
   
   ## Rationale for this change
   
   When `datafusion.execution.target_partitions = 1`, the physical planner 
constructs `WindowAggExec` with `can_repartition = false` so that the window 
stage requires `SinglePartition` distribution and inserts a 
`CoalescePartitionsExec`.
   
   During physical optimization, replacing children via `replace_children` 
under `ChildrenPropertiesMode::Recompute` rebuilt `WindowAggExec` with 
hardcoded `can_repartition = true` instead of propagating 
`self.can_repartition`. This flipped the distribution requirement from 
`SinglePartition` to `KeyPartitioned`, stripping the required coalesce and 
triggering a `SanityCheckPlan` distribution error.
   
   `BoundedWindowAggExec` already correctly propagates `self.can_repartition` 
during `replace_children`. This change aligns `WindowAggExec` with 
`BoundedWindowAggExec`.
   
   ## What changes are included in this PR?
   
   - Pass `self.can_repartition` instead of `true` in 
`WindowAggExec::replace_children` when `ChildrenPropertiesMode::Recompute` is 
used.
   - Added unit test 
`test_window_agg_replace_children_preserves_can_repartition` in 
`window_agg_exec.rs` verifying preservation for both `false` and `true`.
   - Added sqllogictest regression test in `window.slt` verifying query 
execution with `target_partitions = 1`.
   
   ## Are these changes tested?
   
   Yes:
   - Local unit test 
`test_window_agg_replace_children_preserves_can_repartition` passes.
   - Integration test in `datafusion/sqllogictest/test_files/window.slt` passes.
   
   ## Are there any user-facing changes?
   
   No.
   


-- 
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