tustvold opened a new issue, #3691:
URL: https://github.com/apache/arrow-rs/issues/3691

   **Describe the bug**
   <!--
   A clear and concise description of what the bug is.
   -->
   
   `cast_binary_to_string` added in #3624 is unsound as it creates a 
`StringArray` containing invalid UTF-8 data. The data is null, but this is 
insufficient to meet the ArrayData contract which requires all the data be 
valid UTF-8.
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   ```
   #[test]
       fn test_cast_invalid_utf8() {
           let v1: &[u8] = b"\xFF invalid";
           let v2: &[u8] = b"\x00 Foo";
           let s = BinaryArray::from(vec![v1, v2]);
           let options = CastOptions { safe: true };
           let array = cast_with_options(&s, &DataType::Utf8, 
&options).unwrap();
           let a = as_string_array(array.as_ref());
           a.data().validate_full().unwrap();
           
           assert_eq!(a.null_count(), 1);
           assert_eq!(a.len(), 2);
           assert!(a.is_null(0));
           assert_eq!(a.value(0), "");
           assert_eq!(a.value(1), "\x00 Foo");
       }
   ```
   
   **Expected behavior**
   <!--
   A clear and concise description of what you expected to happen.
   -->
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->


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