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/07/03 11:03:39 UTC

[GitHub] [arrow-rs] alamb opened a new issue #519: Allow creation of StringArrays from Vec

alamb opened a new issue #519:
URL: https://github.com/apache/arrow-rs/issues/519


   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   The usecase is I have a Vec of derived `String` values but I can not create a StringArray from them
   
   **Describe the solution you'd like**
   I would like to be able to run:
   ```rust
   let my_array = StringArray::from(v);
   ```
   
   For any `v` that has things that can be borrowed as `str` or `Option<str>` (including `String` and others) rather than only `str`).
   
   It looks like there is some attempt to be able to do this already: https://github.com/apache/arrow-rs/blob/master/arrow/src/array/array_string.rs#L208 but it isn't clear to me why it doesn't work
   
   **Additional context**
   Here is an example
   
   ```rust
   
   fn main() {
       // I want to make a StringArray from a derived type
       let my_data = vec!["Foo", "Bar", "Baz"];
       let my_derived_data = my_data.iter()
           .map(|s| format!("Some transformed data"))
           .collect::<Vec<_>>();
   
       let a = StringArray::from(my_data); // works!
       assert_eq!(a.len(), 3);
   
       // however, if I want to to create a StringArray from an array of Strings, that is no good
       //let b = StringArray::from(my_derived_data); // <----- does not work!
       //assert_eq!(b.len(), 3);
   
   //    |
   // 14 |     let b = StringArray::from(my_derived_data); // does not work!
   //    |             ^^^^^^^^^^^^^^^^^ the trait `From<Vec<String>>` is not implemented for `GenericStringArray<i32>`
   //    |
   //    = help: the following implementations were found:
   //              <GenericStringArray<OffsetSize> as From<ArrayData>>
   //              <GenericStringArray<OffsetSize> as From<Vec<&str>>>
   //              <GenericStringArray<OffsetSize> as From<Vec<Option<&str>>>>
   //              <GenericStringArray<T> as From<GenericListArray<T>>>
   //    = note: required by `from`
   }
   ```


-- 
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



[GitHub] [arrow-rs] alamb closed issue #519: Allow creation of StringArrays from Vec

Posted by GitBox <gi...@apache.org>.
alamb closed issue #519:
URL: https://github.com/apache/arrow-rs/issues/519


   


-- 
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