Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix array equal check #571

Merged
merged 3 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions arrow/src/array/array_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,4 +1090,76 @@ mod tests {
.build();
ListArray::from(list_data);
}

#[test]
fn list_array_equality() {
// test scaffold
fn do_comparison(
lhs_data: Vec<Option<Vec<Option<i32>>>>,
rhs_data: Vec<Option<Vec<Option<i32>>>>,
should_equal: bool,
) {
let lhs = ListArray::from_iter_primitive::<Int32Type, _, _>(lhs_data.clone());
let rhs = ListArray::from_iter_primitive::<Int32Type, _, _>(rhs_data.clone());
assert_eq!(lhs == rhs, should_equal);

let lhs = LargeListArray::from_iter_primitive::<Int32Type, _, _>(lhs_data);
let rhs = LargeListArray::from_iter_primitive::<Int32Type, _, _>(rhs_data);
assert_eq!(lhs == rhs, should_equal);
}

do_comparison(
vec![
Some(vec![Some(0), Some(1), Some(2)]),
None,
Some(vec![Some(3), None, Some(5)]),
Some(vec![Some(6), Some(7)]),
],
vec![
Some(vec![Some(0), Some(1), Some(2)]),
None,
Some(vec![Some(3), None, Some(5)]),
Some(vec![Some(6), Some(7)]),
],
true,
);

do_comparison(
vec![
None,
None,
Some(vec![Some(3), None, Some(5)]),
Some(vec![Some(6), Some(7)]),
],
vec![
Some(vec![Some(0), Some(1), Some(2)]),
None,
Some(vec![Some(3), None, Some(5)]),
Some(vec![Some(6), Some(7)]),
],
false,
);

do_comparison(
vec![
None,
None,
Some(vec![Some(3), None, Some(5)]),
Some(vec![Some(6), Some(7)]),
],
vec![
None,
None,
Some(vec![Some(3), None, Some(5)]),
Some(vec![Some(0), Some(0)]),
],
false,
);

do_comparison(
vec![None, None, Some(vec![Some(1)])],
vec![None, None, Some(vec![Some(2)])],
false,
);
}
}
2 changes: 1 addition & 1 deletion arrow/src/array/equal/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn logical_list_bitmap<OffsetSize: OffsetSizeTrait>(
offsets
.windows(2)
.enumerate()
.take(offset_len - offset_start)
.take(parent_data.len())
.for_each(|(index, window)| {
let start = window[0].to_usize().unwrap();
let end = window[1].to_usize().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/compute/kernels/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ mod tests {
nulls_first: true,
}),
Some(3),
vec![None, None, Some(vec![Some(2)])],
vec![None, None, Some(vec![Some(1)])],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

None,
);

Expand Down