This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 9a4b78780 Fix sparse union array equality (#4044) (#4045)
9a4b78780 is described below
commit 9a4b78780ba106ccc73d7b08a7c3be9aab028806
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Mon Apr 10 21:11:24 2023 +0100
Fix sparse union array equality (#4044) (#4045)
---
arrow-data/src/equal/union.rs | 8 +++++++-
arrow/tests/array_equal.rs | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/arrow-data/src/equal/union.rs b/arrow-data/src/equal/union.rs
index 4f04bc287..5869afc30 100644
--- a/arrow-data/src/equal/union.rs
+++ b/arrow-data/src/equal/union.rs
@@ -70,7 +70,13 @@ fn equal_sparse(
.iter()
.zip(rhs.child_data())
.all(|(lhs_values, rhs_values)| {
- equal_range(lhs_values, rhs_values, lhs_start, rhs_start, len)
+ equal_range(
+ lhs_values,
+ rhs_values,
+ lhs_start + lhs.offset(),
+ rhs_start + rhs.offset(),
+ len,
+ )
})
}
diff --git a/arrow/tests/array_equal.rs b/arrow/tests/array_equal.rs
index 93296c3b0..83a280db6 100644
--- a/arrow/tests/array_equal.rs
+++ b/arrow/tests/array_equal.rs
@@ -1155,6 +1155,22 @@ fn test_union_equal_sparse() {
test_equal(&union1, &union4, false);
}
+#[test]
+fn test_union_equal_sparse_slice() {
+ let mut builder = UnionBuilder::new_sparse();
+ builder.append::<Int32Type>("a", 1).unwrap();
+ builder.append::<Int32Type>("a", 2).unwrap();
+ builder.append::<Int32Type>("b", 3).unwrap();
+ let a1 = builder.build().unwrap();
+
+ let mut builder = UnionBuilder::new_sparse();
+ builder.append::<Int32Type>("a", 2).unwrap();
+ builder.append::<Int32Type>("b", 3).unwrap();
+ let a2 = builder.build().unwrap();
+
+ test_equal(&a1.slice(1, 2), &a2, true)
+}
+
#[test]
fn test_boolean_slice() {
let array = BooleanArray::from(vec![true; 32]);