Created
March 18, 2025 12:54
-
-
Save UBarney/21793799ea91f2c5b556ed0db7be85f5 to your computer and use it in GitHub Desktop.
without `get_filtered_min_of_each_group`.patch
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
diff --git a/datafusion/functions-aggregate/src/first_last.rs b/datafusion/functions-aggregate/src/first_last.rs | |
index 52b12bbc3..c10a35109 100644 | |
--- a/datafusion/functions-aggregate/src/first_last.rs | |
+++ b/datafusion/functions-aggregate/src/first_last.rs | |
@@ -569,16 +569,17 @@ where | |
let mut ordering_buf = Vec::with_capacity(self.ordering_req.len()); | |
- for (group_idx, idx) in self | |
- .get_filtered_min_of_each_group( | |
- &values_with_orderings[1..], | |
- group_indices, | |
- opt_filter, | |
- vals, | |
- None, | |
- )? | |
- .into_iter() | |
- { | |
+ for (idx, group_idx) in group_indices.iter().enumerate() { | |
+ let group_idx = *group_idx; | |
+ | |
+ if self.ignore_nulls && vals.is_null(idx) { | |
+ continue; | |
+ } | |
+ if !(self.need_update(group_idx) && opt_filter.map_or(true, |x| x.value(idx))) | |
+ { | |
+ continue; | |
+ } | |
+ | |
extract_row_at_idx_to_buf( | |
&values_with_orderings[1..], | |
idx, | |
@@ -595,6 +596,32 @@ where | |
} | |
} | |
+ // for (group_idx, idx) in self | |
+ // .get_filtered_min_of_each_group( | |
+ // &values_with_orderings[1..], | |
+ // group_indices, | |
+ // opt_filter, | |
+ // vals, | |
+ // None, | |
+ // )? | |
+ // .into_iter() | |
+ // { | |
+ // extract_row_at_idx_to_buf( | |
+ // &values_with_orderings[1..], | |
+ // idx, | |
+ // &mut ordering_buf, | |
+ // )?; | |
+ | |
+ // if self.should_update_state(group_idx, &ordering_buf)? { | |
+ // self.update_state( | |
+ // group_idx, | |
+ // &ordering_buf, | |
+ // vals.value(idx), | |
+ // vals.is_null(idx), | |
+ // ); | |
+ // } | |
+ // } | |
+ | |
Ok(()) | |
} | |
@@ -656,16 +683,22 @@ where | |
let vals = values[0].as_primitive::<T>(); | |
- let groups = self.get_filtered_min_of_each_group( | |
- &val_and_orderings[1..], | |
- group_indices, | |
- opt_filter, | |
- vals, | |
- Some(is_set_arr), | |
- )?; | |
+ for (idx, group_idx) in group_indices.iter().enumerate() { | |
+ let group_idx = *group_idx; | |
- for (group_idx, idx) in groups.into_iter() { | |
- extract_row_at_idx_to_buf(&val_and_orderings[1..], idx, &mut ordering_buf)?; | |
+ if self.ignore_nulls && vals.is_null(idx) { | |
+ continue; | |
+ } | |
+ if !(self.need_update(group_idx) && opt_filter.map_or(true, |x| x.value(idx)) && is_set_arr.value(idx)) | |
+ { | |
+ continue; | |
+ } | |
+ | |
+ extract_row_at_idx_to_buf( | |
+ &val_and_orderings[1..], | |
+ idx, | |
+ &mut ordering_buf, | |
+ )?; | |
if self.should_update_state(group_idx, &ordering_buf)? { | |
self.update_state( | |
@@ -677,6 +710,27 @@ where | |
} | |
} | |
+ // let groups = self.get_filtered_min_of_each_group( | |
+ // &val_and_orderings[1..], | |
+ // group_indices, | |
+ // opt_filter, | |
+ // vals, | |
+ // Some(is_set_arr), | |
+ // )?; | |
+ | |
+ // for (group_idx, idx) in groups.into_iter() { | |
+ // extract_row_at_idx_to_buf(&val_and_orderings[1..], idx, &mut ordering_buf)?; | |
+ | |
+ // if self.should_update_state(group_idx, &ordering_buf)? { | |
+ // self.update_state( | |
+ // group_idx, | |
+ // &ordering_buf, | |
+ // vals.value(idx), | |
+ // vals.is_null(idx), | |
+ // ); | |
+ // } | |
+ // } | |
+ | |
Ok(()) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment