viirya commented on code in PR #5015:
URL: https://github.com/apache/arrow-rs/pull/5015#discussion_r1379051814
##########
arrow-cast/src/cast.rs:
##########
@@ -2317,6 +2341,22 @@ fn value_to_string<O: OffsetSizeTrait>(
Ok(Arc::new(builder.finish()))
}
+fn cast_numeric_to_binary<FROM: ArrowPrimitiveType, O: OffsetSizeTrait>(
+ array: &dyn Array,
+) -> Result<ArrayRef, ArrowError> {
+ let array = array.as_primitive::<FROM>();
+
+ let mut builder = GenericBinaryBuilder::<O>::new();
+ for i in 0..array.len() {
+ if array.is_null(i) {
+ builder.append_null();
+ } else {
+ builder.append_value(array.value(i).to_byte_slice());
+ }
+ }
Review Comment:
Hmm, `v` is not `AsRef<[u8]>` though.
```
2352 | builder.append_option(v);
| ------------- ^ the trait `AsRef<[u8]>` is not
implemented for `<FROM as arrow_array::ArrowPrimitiveType>::Native`
| |
| required by a bound introduced by this call
```
But I also cannot do `builder.append_option(v.map(|v| v.to_byte_slice()));`
too as it complains `returns a value referencing data owned by the current
function`.
I keep it unchanged so.
--
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]