alamb commented on code in PR #5340:
URL: https://github.com/apache/arrow-rs/pull/5340#discussion_r1477311979
##########
arrow-cast/src/cast.rs:
##########
@@ -7609,6 +7626,36 @@ mod tests {
assert_eq!(expected.values(), actual.values());
}
+ #[test]
+ fn test_cast_utf8_to_list() {
+ // DataType::List
+ let array = Arc::new(StringArray::from(vec!["5"])) as ArrayRef;
+ let field = Arc::new(Field::new("", DataType::Int32, false));
+ let list_array = cast(&array, &DataType::List(field.clone())).unwrap();
+ let actual = list_array.as_any().downcast_ref::<ListArray>().unwrap();
+ let expect = ListArray::from_iter_primitive::<Int32Type, _,
_>([Some([Some(5)])]);
+ assert_eq!(&expect.value(0), &actual.value(0));
+
+ // DataType::LargeList
+ let list_array = cast(&array,
&DataType::LargeList(field.clone())).unwrap();
+ let actual = list_array
+ .as_any()
+ .downcast_ref::<LargeListArray>()
+ .unwrap();
+ let expect = LargeListArray::from_iter_primitive::<Int32Type, _,
_>([Some([Some(5)])]);
+ assert_eq!(&expect.value(0), &actual.value(0));
Review Comment:
This results in a compile error:
```
7644 | assert_eq!(expect.value(0), actual.value(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs
because `*right_val` has type `std::sync::Arc<dyn arrow_array::Array>`, which
does not implement the `Copy` trait
|
```
--
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]