From d4357ec42b7759402a60020266ca64508f8fa99a Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Sat, 17 Feb 2024 11:15:43 -0800 Subject: [PATCH] Add more doc to InputOrderMode (#9255) --- datafusion/physical-plan/src/ordering.rs | 11 +++++++---- datafusion/physical-plan/src/windows/mod.rs | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/datafusion/physical-plan/src/ordering.rs b/datafusion/physical-plan/src/ordering.rs index 047f89eef193..8b596b9cb23e 100644 --- a/datafusion/physical-plan/src/ordering.rs +++ b/datafusion/physical-plan/src/ordering.rs @@ -28,11 +28,14 @@ /// - A `PARTITION BY a, b` or a `PARTITION BY b, a` can use `Sorted` mode. /// /// ## Aggregations -/// - A `GROUP BY b` clause can use `Linear` mode. -/// - A `GROUP BY a, c` or a `GROUP BY BY c, a` can use -/// `PartiallySorted([0])` or `PartiallySorted([1])` modes, respectively. +/// - A `GROUP BY b` clause can use `Linear` mode, as the only one permutation `[b]` +/// cannot satisfy the existing ordering. +/// - A `GROUP BY a, c` or a `GROUP BY c, a` can use +/// `PartiallySorted([0])` or `PartiallySorted([1])` modes, respectively, as +/// the permutation `[a]` satisfies the existing ordering. /// (The vector stores the index of `a` in the respective PARTITION BY expression.) -/// - A `GROUP BY a, b` or a `GROUP BY b, a` can use `Sorted` mode. +/// - A `GROUP BY a, b` or a `GROUP BY b, a` can use `Sorted` mode, as the +/// full permutation `[a, b]` satisfies the existing ordering. /// /// Note these are the same examples as above, but with `GROUP BY` instead of /// `PARTITION BY` to make the examples easier to read. diff --git a/datafusion/physical-plan/src/windows/mod.rs b/datafusion/physical-plan/src/windows/mod.rs index 01818405b810..693d20e90a66 100644 --- a/datafusion/physical-plan/src/windows/mod.rs +++ b/datafusion/physical-plan/src/windows/mod.rs @@ -329,11 +329,11 @@ pub(crate) fn calc_requirements< (!sort_reqs.is_empty()).then_some(sort_reqs) } -/// This function calculates the indices such that when partition by expressions reordered with this indices +/// This function calculates the indices such that when partition by expressions reordered with the indices /// resulting expressions define a preset for existing ordering. -// For instance, if input is ordered by a, b, c and PARTITION BY b, a is used -// This vector will be [1, 0]. It means that when we iterate b,a columns with the order [1, 0] -// resulting vector (a, b) is a preset of the existing ordering (a, b, c). +/// For instance, if input is ordered by a, b, c and PARTITION BY b, a is used, +/// this vector will be [1, 0]. It means that when we iterate b, a columns with the order [1, 0] +/// resulting vector (a, b) is a preset of the existing ordering (a, b, c). pub(crate) fn get_ordered_partition_by_indices( partition_by_exprs: &[Arc], input: &Arc,