alamb opened a new issue, #6531: URL: https://github.com/apache/arrow-rs/issues/6531
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** While working on https://github.com/apache/datafusion/issues/12788#issuecomment-2400448053 with StringView upstream in DataFusion, @goldmedal found that casting from `BinaryArray` --> `Utf8View` is not supported **Describe the solution you'd like** Support casting BinaryArray --> Utf8View **Describe alternatives you've considered** Here is a modified `test_binary_to_view` test that should pass ```rust #[test] fn test_binary_to_view() { _test_binary_to_view::<i32>(); _test_binary_to_view::<i64>(); } fn _test_binary_to_view<O>() where O: OffsetSizeTrait, { let binary_array = GenericBinaryArray::<O>::from_iter(VIEW_TEST_DATA); assert!(can_cast_types( binary_array.data_type(), &DataType::Utf8View )); assert!(can_cast_types( binary_array.data_type(), &DataType::BinaryView )); let string_view_array = cast(&binary_array, &DataType::Utf8View).unwrap(); assert_eq!(string_view_array.data_type(), &DataType::Utf8View); let binary_view_array = cast(&binary_array, &DataType::BinaryView).unwrap(); assert_eq!(binary_view_array.data_type(), &DataType::BinaryView); let expect_string_view_array = StringViewArray::from_iter(VIEW_TEST_DATA); assert_eq!(string_view_array.as_ref(), &expect_string_view_array); let expect_binary_view_array = BinaryViewArray::from_iter(VIEW_TEST_DATA); assert_eq!(binary_view_array.as_ref(), &expect_binary_view_array); } ``` <details><summary>Full Diff</summary> <p> ```diff diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs index e3fad3da19..f147a9c3f6 100644 --- a/arrow-cast/src/cast/mod.rs +++ b/arrow-cast/src/cast/mod.rs @@ -5523,7 +5523,7 @@ mod tests { } #[test] - fn test_bianry_to_view() { + fn test_binary_to_view() { _test_binary_to_view::<i32>(); _test_binary_to_view::<i64>(); } @@ -5534,14 +5534,25 @@ mod tests { { let binary_array = GenericBinaryArray::<O>::from_iter(VIEW_TEST_DATA); + assert!(can_cast_types( + binary_array.data_type(), + &DataType::Utf8View + )); + assert!(can_cast_types( binary_array.data_type(), &DataType::BinaryView )); + let string_view_array = cast(&binary_array, &DataType::Utf8View).unwrap(); + assert_eq!(string_view_array.data_type(), &DataType::Utf8View); + let binary_view_array = cast(&binary_array, &DataType::BinaryView).unwrap(); assert_eq!(binary_view_array.data_type(), &DataType::BinaryView); + let expect_string_view_array = StringViewArray::from_iter(VIEW_TEST_DATA); + assert_eq!(string_view_array.as_ref(), &expect_string_view_array); + let expect_binary_view_array = BinaryViewArray::from_iter(VIEW_TEST_DATA); assert_eq!(binary_view_array.as_ref(), &expect_binary_view_array); } ``` </p> </details> **Additional context** <!-- Add any other context or screenshots about the feature request 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]
