From 49ab8933c1177e312685b451a28eb31e7aff49b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alihan=20=C3=87elikcan?= Date: Tue, 24 Dec 2024 16:34:02 +0300 Subject: [PATCH 1/3] Implement maintains_input_order for AggregateExec --- datafusion/physical-plan/src/aggregates/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 2e0103defd9f..36c6d173bd6c 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -792,6 +792,11 @@ impl ExecutionPlan for AggregateExec { vec![self.required_input_ordering.clone()] } + fn maintains_input_order(&self) -> Vec { + // See: InputOrderMode documentation for aggregations + vec![self.input_order_mode != InputOrderMode::Linear] + } + fn children(&self) -> Vec<&Arc> { vec![&self.input] } From 50acc71cf2eda12a7abc23756310e1ce825eaa7c Mon Sep 17 00:00:00 2001 From: berkaysynnada Date: Wed, 25 Dec 2024 18:22:19 +0300 Subject: [PATCH 2/3] Update mod.rs --- datafusion/physical-plan/src/aggregates/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 36c6d173bd6c..33352ee3ff21 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -792,8 +792,17 @@ impl ExecutionPlan for AggregateExec { vec![self.required_input_ordering.clone()] } + /// The output ordering of [`AggregateExec`] is determined by its `group_by` columns. + /// Although this method is not explicitly used by any optimizer rules, overriding + /// the default implementation ensures it accurately reflects the actual behavior. + /// + /// If the [`InputOrderMode`] is `Linear`, the `group_by` columns are unordered, + /// which means the results are also unordered. However, in the `Ordered` and + /// `PartiallyOrdered` cases, the `group_by` columns are ordered, and their + /// order is preserved in the output results. + /// + /// See: InputOrderMode documentation for aggregations fn maintains_input_order(&self) -> Vec { - // See: InputOrderMode documentation for aggregations vec![self.input_order_mode != InputOrderMode::Linear] } From 7a75b6a58dfc3740e8a8fa129fde3dc4e2900ea8 Mon Sep 17 00:00:00 2001 From: Mehmet Ozan Kabak Date: Fri, 27 Dec 2024 12:37:51 +0300 Subject: [PATCH 3/3] Improve comments --- datafusion/physical-plan/src/aggregates/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 33352ee3ff21..c04211d679ca 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -792,16 +792,15 @@ impl ExecutionPlan for AggregateExec { vec![self.required_input_ordering.clone()] } - /// The output ordering of [`AggregateExec`] is determined by its `group_by` columns. - /// Although this method is not explicitly used by any optimizer rules, overriding - /// the default implementation ensures it accurately reflects the actual behavior. + /// The output ordering of [`AggregateExec`] is determined by its `group_by` + /// columns. Although this method is not explicitly used by any optimizer + /// rules yet, overriding the default implementation ensures that it + /// accurately reflects the actual behavior. /// - /// If the [`InputOrderMode`] is `Linear`, the `group_by` columns are unordered, - /// which means the results are also unordered. However, in the `Ordered` and - /// `PartiallyOrdered` cases, the `group_by` columns are ordered, and their - /// order is preserved in the output results. - /// - /// See: InputOrderMode documentation for aggregations + /// If the [`InputOrderMode`] is `Linear`, the `group_by` columns don't have + /// an ordering, which means the results do not either. However, in the + /// `Ordered` and `PartiallyOrdered` cases, the `group_by` columns do have + /// an ordering, which is preserved in the output. fn maintains_input_order(&self) -> Vec { vec![self.input_order_mode != InputOrderMode::Linear] }