Skip to content

Commit 33b3267

Browse files
committed
feat: allow Range partitioning to satisfy KeyPartitioned requirement for Window/TopK
1 parent 3457fb7 commit 33b3267

3 files changed

Lines changed: 334 additions & 3 deletions

File tree

datafusion/physical-optimizer/src/window_topn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,15 @@ fn supported_window_fn(
329329
}
330330
}
331331

332+
type PlanAndIntermediates = (Arc<dyn ExecutionPlan>, Vec<Arc<dyn ExecutionPlan>>);
333+
332334
/// Walk below a plan node looking for a [`BoundedWindowAggExec`].
333335
///
334336
/// Handles sequences of `ProjectionExec` and `RepartitionExec`.
335337
///
336338
/// Returns the window exec and a list of intermediate nodes to rebuild,
337339
/// or `None` if no `BoundedWindowAggExec` is found.
338-
fn find_window_below(
339-
plan: &Arc<dyn ExecutionPlan>,
340-
) -> Option<(Arc<dyn ExecutionPlan>, Vec<Arc<dyn ExecutionPlan>>)> {
340+
fn find_window_below(plan: &Arc<dyn ExecutionPlan>) -> Option<PlanAndIntermediates> {
341341
let mut current = Arc::clone(plan);
342342
let mut intermediates = Vec::new();
343343

datafusion/physical-plan/src/sorts/partitioned_topk.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ impl ExecutionPlan for PartitionedTopKExec {
355355
crate::InputDistributionRequirements::new(vec![Distribution::KeyPartitioned(
356356
partition_exprs,
357357
)])
358+
.allow_range_satisfaction_for_key_partitioning()
358359
}
359360

360361
fn maintains_input_order(&self) -> Vec<bool> {

0 commit comments

Comments
 (0)