Skip to content

Commit

Permalink
Fix slicing already sliced RunEndArray (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Sep 10, 2024
1 parent 84628c3 commit d73da01
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion encodings/runend/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl SliceFn for RunEndArray {
slice(&self.values(), slice_begin, slice_end + 1)?,
self.validity().slice(start, stop)?,
stop - start,
start,
start + self.offset(),
)?
.into_array())
}
Expand Down Expand Up @@ -225,6 +225,33 @@ mod test {
);
}

#[test]
fn double_slice() {
let arr = slice(
RunEndArray::try_new(
vec![2u32, 5, 10].into_array(),
vec![1i32, 2, 3].into_array(),
Validity::NonNullable,
)
.unwrap()
.array(),
3,
8,
)
.unwrap();
assert_eq!(arr.len(), 5);

let doubly_sliced = slice(&arr, 0, 3).unwrap();

assert_eq!(
doubly_sliced
.into_primitive()
.unwrap()
.maybe_null_slice::<i32>(),
vec![2, 2, 3]
);
}

#[test]
fn slice_end_inclusive() {
let arr = slice(
Expand Down

0 comments on commit d73da01

Please sign in to comment.