Skip to content

Commit

Permalink
Test for list array equality with different offsets (#1756)
Browse files Browse the repository at this point in the history
* Test for list array equality with different offsets

* fix: make it compile
  • Loading branch information
alamb committed May 26, 2022
1 parent 3e9e9df commit 7e8fbf9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion arrow/src/array/equal/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ pub(super) fn list_equal<T: OffsetSizeTrait>(

#[cfg(test)]
mod tests {
use crate::array::{Int64Builder, ListBuilder};
use crate::{
array::{Array, Int64Builder, ListArray, ListBuilder},
datatypes::Int32Type,
};

#[test]
fn list_array_non_zero_nulls() {
Expand All @@ -172,4 +175,21 @@ mod tests {

assert_eq!(array1, array2);
}

#[test]
fn test_list_different_offsets() {
let a = ListArray::from_iter_primitive::<Int32Type, _, _>([
Some([Some(0), Some(0)]),
Some([Some(1), Some(2)]),
Some([None, None]),
]);
let b = ListArray::from_iter_primitive::<Int32Type, _, _>([
Some([Some(1), Some(2)]),
Some([None, None]),
Some([None, None]),
]);
let a_slice = a.slice(1, 2);
let b_slice = b.slice(0, 2);
assert_eq!(&a_slice, &b_slice);
}
}

0 comments on commit 7e8fbf9

Please sign in to comment.