Repository navigation
fix: preserve can_repartition in WindowAggExec::replace_children (#26626) - #26675
Open
XiaoMingFa wants to merge 1 commit into
Open
XiaoMingFa wants to merge 1 commit into
XiaoMingFa wants to merge 1 commit into
Conversation
…che#26626) ## Which issue does this PR close? - Closes apache#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` passed. - Integration test added to `window.slt`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
target_partitions = 1(WindowAggExeclosescan_repartitionwhen its children are replaced) #26626.Rationale for this change
When
datafusion.execution.target_partitions = 1, the physical planner constructsWindowAggExecwithcan_repartition = falseso that the window stage requiresSinglePartitiondistribution and inserts aCoalescePartitionsExec.During physical optimization, replacing children via
replace_childrenunderChildrenPropertiesMode::RecomputerebuiltWindowAggExecwith hardcodedcan_repartition = trueinstead of propagatingself.can_repartition. This flipped the distribution requirement fromSinglePartitiontoKeyPartitioned, stripping the required coalesce and triggering aSanityCheckPlandistribution error.BoundedWindowAggExecalready correctly propagatesself.can_repartitionduringreplace_children. This change alignsWindowAggExecwithBoundedWindowAggExec.What changes are included in this PR?
self.can_repartitioninstead oftrueinWindowAggExec::replace_childrenwhenChildrenPropertiesMode::Recomputeis used.test_window_agg_replace_children_preserves_can_repartitioninwindow_agg_exec.rsverifying preservation for bothfalseandtrue.window.sltverifying query execution withtarget_partitions = 1.Are these changes tested?
Yes:
test_window_agg_replace_children_preserves_can_repartitionpasses.datafusion/sqllogictest/test_files/window.sltpasses.Are there any user-facing changes?
No.