diff --git a/arrow-array/src/array/byte_view_array.rs b/arrow-array/src/array/byte_view_array.rs index 9eb59865177c..a35df0d200be 100644 --- a/arrow-array/src/array/byte_view_array.rs +++ b/arrow-array/src/array/byte_view_array.rs @@ -54,19 +54,6 @@ use super::ByteArrayType; /// /// [`ByteView`]: arrow_data::ByteView /// -/// # Use the [`eq`] kernel to compare the logical content. -/// -/// Comparing two `GenericByteViewArray` using PartialEq compares by structure -/// (the `u128`s) and contents of the buffers, not by logical content. As there -/// are many different buffer layouts to represent the same data (e.g. different -/// offsets, different buffer sizes, etc) two arrays with the same data may not -/// compare equal. -/// -/// To compare the logical content of two `GenericByteViewArray`s, use the [`eq`] -/// kernel. -/// -/// [`eq`]: https://docs.rs/arrow/latest/arrow/compute/kernels/cmp/fn.eq.html -/// /// # Layout: "views" and buffers /// /// A `GenericByteViewArray` stores variable length byte strings. An array of @@ -192,16 +179,6 @@ impl Clone for GenericByteViewArray { } } -// PartialEq -impl PartialEq for GenericByteViewArray { - fn eq(&self, other: &Self) -> bool { - other.data_type.eq(&self.data_type) - && other.views.eq(&self.views) - && other.buffers.eq(&self.buffers) - && other.nulls.eq(&self.nulls) - } -} - impl GenericByteViewArray { /// Create a new [`GenericByteViewArray`] from the provided parts, panicking on failure /// @@ -1065,6 +1042,6 @@ mod tests { }; assert_eq!(array1, array1.clone()); assert_eq!(array2, array2.clone()); - assert_ne!(array1, array2); + assert_eq!(array1, array2); } } diff --git a/arrow-array/src/array/mod.rs b/arrow-array/src/array/mod.rs index 7ca59680a6fe..4a9e54a60789 100644 --- a/arrow-array/src/array/mod.rs +++ b/arrow-array/src/array/mod.rs @@ -654,6 +654,12 @@ impl PartialEq for StructArray { } } +impl PartialEq for GenericByteViewArray { + fn eq(&self, other: &Self) -> bool { + self.to_data().eq(&other.to_data()) + } +} + /// Constructs an array using the input `data`. /// Returns a reference-counted `Array` instance. pub fn make_array(data: ArrayData) -> ArrayRef {