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/12/08 18:44:29 UTC

[GitHub] [arrow-rs] alamb commented on pull request #984: Add comparison kernels for DictionaryArray

alamb commented on pull request #984:
URL: https://github.com/apache/arrow-rs/pull/984#issuecomment-989085691


   
   > one thing i noticed is that it doesnt seem there is way to create a DictionaryArray from a vec of scalars like you can with a vec of str slices.
   
   You can create `DictionaryArrays` from `&str`  using `FromIter` as shown in https://docs.rs/arrow/6.3.0/arrow/array/struct.DictionaryArray.html
   
   ```
   use arrow::array::{DictionaryArray, Int8Array};
   use arrow::datatypes::Int8Type;
   let test = vec!["a", "a", "b", "c"];
   let array : DictionaryArray<Int8Type> = test.iter().map(|&x| if x == "b" {None} else {Some(x)}).collect();
   assert_eq!(array.keys(), &Int8Array::from(vec![Some(0), Some(0), None, Some(1)]));
   ```
   
   There isn't an equivalent syntax for other scalar types (e.g. `u32`, `u64`, etc) though we could add them


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