alamb commented on a change in pull request #9211:
URL: https://github.com/apache/arrow/pull/9211#discussion_r558844335



##########
File path: rust/arrow/src/array/equal/mod.rs
##########
@@ -541,6 +541,15 @@ mod tests {
         test_generic_binary_equal::<i64>()
     }
 
+    #[test]
+    fn test_string_offset() {
+        let a = StringArray::from(vec![Some("a"), None, Some("b")]).data();
+        let a = a.slice(2, 1);
+        let b = StringArray::from(vec![Some("b")]).data();
+
+        test_equal(&a, b.as_ref(), true);
+    }
+

Review comment:
       I may be missing something, but I tried a few more test cases and there 
still seems to be something wrong.
   
   Namely I would expect this test to pass:
   ```
       #[test]
       fn test_string_offset_larger() {
           let a = StringArray::from(vec![Some("a"), None, Some("b"), None, 
Some("c")]).data();
           let b = StringArray::from(vec![None, Some("b"), None, 
Some("c")]).data();
   
           test_equal(&a.slice(2,2), &b.slice(0,2), false);
           test_equal(&a.slice(2,2), &b.slice(1,2), true);
           test_equal(&a.slice(2,2), &b.slice(2,2), false);
       }
   ```
   
   But instead if fails 
   
   ```
   ---- array::equal::tests::test_string_offset_larger stdout ----
   thread 'array::equal::tests::test_string_offset_larger' panicked at 
'assertion failed: `(left == right)`
     left: `false`,
    right: `true`: 
   ArrayData { data_type: Utf8, len: 2, null_count: 1, offset: 2, buffers: 
[Buffer { data: Bytes { ptr: 0x7fbc90504480, len: 24, data: [0, 0, 0, 0, 1, 0, 
0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0] }, offset: 0 }, Buffer { 
data: Bytes { ptr: 0x7fbc90504500, len: 3, data: [97, 98, 99] }, offset: 0 }], 
child_data: [], null_bitmap: Some(Bitmap { bits: Buffer { data: Bytes { ptr: 
0x7fbc90504580, len: 1, data: [21] }, offset: 0 } }) }
   ArrayData { data_type: Utf8, len: 2, null_count: 1, offset: 1, buffers: 
[Buffer { data: Bytes { ptr: 0x7fbc90604700, len: 20, data: [0, 0, 0, 0, 0, 0, 
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0] }, offset: 0 }, Buffer { data: Bytes 
{ ptr: 0x7fbc90604880, len: 2, data: [98, 99] }, offset: 0 }], child_data: [], 
null_bitmap: Some(Bitmap { bits: Buffer { data: Bytes { ptr: 0x7fbc90604780, 
len: 1, data: [10] }, offset: 0 } }) }', arrow/src/array/equal/mod.rs:457:9
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to