You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/08/05 00:54:03 UTC
[GitHub] [arrow-rs] alamb commented on issue #587: Can't cast from string to timestamp:
alamb commented on issue #587:
URL: https://github.com/apache/arrow-rs/issues/587#issuecomment-893079145
Thanks @sum12 ! think the trait you want is `ArrowTemporalType` https://docs.rs/arrow/5.1.0/arrow/datatypes/trait.ArrowTemporalType.html
So then you could write a function like:
```rust
fn temporal_array_to_string<T>(array: &PrimitiveArray<T>) -> Result<ArrayRef>
where
T: ArrowTemporalType,
{
// ... call array.value_as_datetime here as appropriate
}
```
And then to call it you might do something like:
```rust
let timestamp_array = array.as_any().downcast_ref::<TimestampNanosecondArray>().unwrap();
temporal_array_to_string(timestamp_array)
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org