Skip to content

Commit

Permalink
fix(rust, python): fix generic streaming groupby on logical types (po…
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored and zundertj committed Jan 7, 2023
1 parent ab7fc17 commit 300ad43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl<'a> AnyValueBuffer<'a> {
}
}

pub fn new(dtype: &DataType, capacity: usize) -> AnyValueBuffer<'_> {
pub fn new(dtype: &DataType, capacity: usize) -> AnyValueBuffer<'a> {
(dtype, capacity).into()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl GenericGroupbySink {
.output_schema
.iter_dtypes()
.take(n_keys)
.map(|dtype| AnyValueBuffer::new(dtype, agg_map.len()))
.map(|dtype| AnyValueBuffer::new(&dtype.to_physical(), agg_map.len()))
.collect::<Vec<_>>();
let dtypes = agg_fns
.iter()
Expand Down Expand Up @@ -251,15 +251,17 @@ impl Sink for GenericGroupbySink {
let current_key_values = unsafe { self.keys.get_unchecked_release_mut(partition) };

let entry = current_partition.raw_entry_mut().from_hash(h, |key| {
let idx = key.idx as usize;
if self.keys_series.len() > 1 {
current_tuple.iter().enumerate().all(|(i, key)| unsafe {
current_key_values.get_unchecked_release(i + idx) == key
})
} else {
unsafe {
current_key_values.get_unchecked_release(idx)
== current_tuple.get_unchecked_release(0)
key.hash == h && {
let idx = key.idx as usize;
if self.keys_series.len() > 1 {
current_tuple.iter().enumerate().all(|(i, key)| unsafe {
current_key_values.get_unchecked_release(i + idx) == key
})
} else {
unsafe {
current_key_values.get_unchecked_release(idx)
== current_tuple.get_unchecked_release(0)
}
}
}
});
Expand Down

0 comments on commit 300ad43

Please sign in to comment.