alamb commented on code in PR #6816:
URL: https://github.com/apache/arrow-rs/pull/6816#discussion_r1864869334
##########
arrow-cast/src/cast/mod.rs:
##########
@@ -3707,6 +3713,56 @@ mod tests {
assert_eq!(10.0, c.value(3));
}
+ #[test]
+ fn test_cast_int_to_utf8view() {
+ let inputs = vec![
+ Arc::new(Int8Array::from(vec![None, Some(8), Some(9), Some(10)]))
as ArrayRef,
+ Arc::new(Int16Array::from(vec![None, Some(8), Some(9), Some(10)]))
as ArrayRef,
+ Arc::new(Int32Array::from(vec![None, Some(8), Some(9), Some(10)]))
as ArrayRef,
+ Arc::new(Int64Array::from(vec![None, Some(8), Some(9), Some(10)]))
as ArrayRef,
+ Arc::new(UInt8Array::from(vec![None, Some(8), Some(9), Some(10)]))
as ArrayRef,
+ Arc::new(UInt16Array::from(vec![None, Some(8), Some(9),
Some(10)])) as ArrayRef,
+ Arc::new(UInt32Array::from(vec![None, Some(8), Some(9),
Some(10)])) as ArrayRef,
+ Arc::new(UInt64Array::from(vec![None, Some(8), Some(9),
Some(10)])) as ArrayRef,
+ ];
+ let expected: ArrayRef = Arc::new(StringViewArray::from(vec![
+ None,
+ Some("8"),
+ Some("9"),
+ Some("10"),
+ ]));
+
+ for array in inputs {
+ assert!(can_cast_types(array.data_type(), &DataType::Utf8View));
+ let arr = cast(&array, &DataType::Utf8View).unwrap();
+ assert_eq!(expected.as_ref(), arr.as_ref());
+ }
+ }
+
+ #[test]
+ fn test_cast_float_to_utf8view() {
+ let inputs = vec![
+ Arc::new(Float16Array::from(vec![
+ Some(f16::from_f64(1.0)),
Review Comment:
Doh -- I swear I ran these tests but clearly not. Fixed
--
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]