Skip to content

Commit

Permalink
closer
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Oct 7, 2024
1 parent 5a07415 commit 7a872c1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions datafusion/functions-aggregate/src/min_max/min_max_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

use arrow::array::{Array, ArrayRef, AsArray, BooleanArray, GenericStringArray, OffsetSizeTrait};
use arrow_schema::DataType;
use datafusion_common::{internal_err, not_impl_err, Result};
use datafusion_common::{internal_err,Result};
use datafusion_expr::{EmitTo, GroupsAccumulator};
use datafusion_functions_aggregate_common::aggregate::groups_accumulator::accumulate::NullState;

/// Implements Min/Max accumulators for "bytes" types ([`StringArray`], [`BinaryArray`], etc)
///
Expand Down Expand Up @@ -104,6 +103,11 @@ impl MinMaxBytesAccumulator {
match location {
MinMaxLocation::ExistingMinMax => {}
MinMaxLocation::Input(new_val) => {
match self.min_max[group_index].as_mut() {
None => self.min_max[group_index] = Some(new_val.to_string()),
// TODO avoid allocating here (TODO check if this is necessary)
Some(existing_val) => *existing_val = String::from(*new_val),
}
self.min_max[group_index] = Some(new_val.to_string());
}
}
Expand Down Expand Up @@ -156,7 +160,8 @@ impl GroupsAccumulator for MinMaxBytesAccumulator {
opt_filter: Option<&BooleanArray>,
total_num_groups: usize,
) -> Result<()> {
todo!()
// min/max are their own states (no transition needed)
self.update_batch(values, group_indices, opt_filter, total_num_groups)
}

fn size(&self) -> usize {
Expand Down

0 comments on commit 7a872c1

Please sign in to comment.