From ab2e74d961187f422a683d2c7f0e795f5f6f68e1 Mon Sep 17 00:00:00 2001 From: Mustafa Akur Date: Wed, 15 Nov 2023 14:16:58 +0300 Subject: [PATCH] Remove unused Results --- datafusion/physical-plan/src/aggregates/mod.rs | 10 +++++----- datafusion/physical-plan/src/windows/mod.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 3ac8129297728..7d7fba6ef6c31 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -405,7 +405,7 @@ fn get_aggregate_search_mode( aggr_expr: &mut [Arc], order_by_expr: &mut [Option], ordering_req: &mut Vec, -) -> Result { +) -> PartitionSearchMode { let groupby_exprs = group_by .expr .iter() @@ -413,11 +413,11 @@ fn get_aggregate_search_mode( .collect::>(); let mut partition_search_mode = PartitionSearchMode::Linear; if !group_by.is_single() || groupby_exprs.is_empty() { - return Ok(partition_search_mode); + return partition_search_mode; } if let Some((should_reverse, mode)) = - get_window_mode(&groupby_exprs, ordering_req, input)? + get_window_mode(&groupby_exprs, ordering_req, input) { let all_reversible = aggr_expr .iter() @@ -437,7 +437,7 @@ fn get_aggregate_search_mode( } partition_search_mode = mode; } - Ok(partition_search_mode) + partition_search_mode } /// Check whether group by expression contains all of the expression inside `requirement` @@ -513,7 +513,7 @@ impl AggregateExec { &mut aggr_expr, &mut order_by_expr, &mut ordering_req, - )?; + ); // Get GROUP BY expressions: let groupby_exprs = group_by.input_exprs(); diff --git a/datafusion/physical-plan/src/windows/mod.rs b/datafusion/physical-plan/src/windows/mod.rs index 541192c00d0c0..d97e3c93a1362 100644 --- a/datafusion/physical-plan/src/windows/mod.rs +++ b/datafusion/physical-plan/src/windows/mod.rs @@ -405,7 +405,7 @@ pub fn get_best_fitting_window( let orderby_keys = window_exprs[0].order_by(); let (should_reverse, partition_search_mode) = if let Some((should_reverse, partition_search_mode)) = - get_window_mode(partitionby_exprs, orderby_keys, input)? + get_window_mode(partitionby_exprs, orderby_keys, input) { (should_reverse, partition_search_mode) } else { @@ -467,12 +467,12 @@ pub fn get_best_fitting_window( /// can run with existing input ordering, so we can remove `SortExec` before it. /// The `bool` field in the return value represents whether we should reverse window /// operator to remove `SortExec` before it. The `PartitionSearchMode` field represents -/// the mode this window operator should work in to accomodate the existing ordering. +/// the mode this window operator should work in to accommodate the existing ordering. pub fn get_window_mode( partitionby_exprs: &[Arc], orderby_keys: &[PhysicalSortExpr], input: &Arc, -) -> Result> { +) -> Option<(bool, PartitionSearchMode)> { let input_eqs = input.equivalence_properties(); let mut partition_by_reqs: Vec = vec![]; let (_, indices) = input_eqs.find_longest_permutation(partitionby_exprs); @@ -499,10 +499,10 @@ pub fn get_window_mode( } else { PartitionSearchMode::PartiallySorted(indices) }; - return Ok(Some((should_swap, mode))); + return Some((should_swap, mode)); } } - Ok(None) + None } #[cfg(test)] @@ -869,7 +869,7 @@ mod tests { order_by_exprs.push(PhysicalSortExpr { expr, options }); } let res = - get_window_mode(&partition_by_exprs, &order_by_exprs, &exec_unbounded)?; + get_window_mode(&partition_by_exprs, &order_by_exprs, &exec_unbounded); // Since reversibility is not important in this test. Convert Option<(bool, PartitionSearchMode)> to Option let res = res.map(|(_, mode)| mode); assert_eq!( @@ -1033,7 +1033,7 @@ mod tests { } assert_eq!( - get_window_mode(&partition_by_exprs, &order_by_exprs, &exec_unbounded)?, + get_window_mode(&partition_by_exprs, &order_by_exprs, &exec_unbounded), *expected, "Unexpected result for in unbounded test case#: {case_idx:?}, case: {test_case:?}" );