Jefffrey commented on issue #9018:
URL: https://github.com/apache/arrow-rs/issues/9018#issuecomment-3692433972

   I've checked the code base as best I could, and these are the other places I 
think we need to fix:
   
   **arrow-row**
   
   Doesn't account for slicing so can panic, see example test:
   
   ```rust
   // arrow-row/src/run.rs
   #[test]
   fn test_run_end_encoded_round_trip_sliced() {
       let values = Int64Array::from(vec![100, 200, 100, 300]);
       let run_ends = vec![2, 3, 5, 6];
       let array: RunArray<Int16Type> =
           RunArray::try_new(&PrimitiveArray::from(run_ends), &values).unwrap();
       let array = array.slice(2, 3);
   
       assert_roundtrip(&array, DataType::Int16, DataType::Int64, None);
   }
   ```
   
   **arrow-cast - casting between RunArrays**
   
   In the issue body I listed cast but that was for casting from RunArray to 
another type; here is a test to cast between RunArrays which fails:
   
   ```rust
   // arrow-cast/src/cast/mod.rs
   #[test]
   fn test_cast_between_sliced_run_end_encoded() {
       let run_ends = Int16Array::from(vec![2, 5, 8]);
       let values = StringArray::from(vec!["a", "b", "c"]);
   
       let ree_array = RunArray::<Int16Type>::try_new(&run_ends, 
&values).unwrap();
       let ree_array = ree_array.slice(1, 2);
       let array_ref = Arc::new(ree_array) as ArrayRef;
   
       let target_type = DataType::RunEndEncoded(
           Arc::new(Field::new("run_ends", DataType::Int64, false)),
           Arc::new(Field::new("values", DataType::Utf8, true)),
       );
       let cast_options = CastOptions {
           safe: false,
           format_options: FormatOptions::default(),
       };
   
       let result = cast_with_options(&array_ref, &target_type, 
&cast_options).unwrap();
       let run_array = result.as_run::<Int64Type>();
       let run_array = run_array.downcast::<StringArray>().unwrap();
   
       let expected = vec!["a", "b"];
       let actual = run_array.into_iter().flatten().collect::<Vec<_>>();
   
       assert_eq!(expected, actual);
   }
   ```
   
   **arrow-data - equal**
   
   It explicitly doesn't support slices yet, so at least it doesn't silently 
have buggy behaviour. Should look into implementing it:
   
   
https://github.com/apache/arrow-rs/blob/b80d457e6e1689e077a635f8b03afdc4be4fa06a/arrow-data/src/equal/run.rs#L26-L40


-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to