tustvold commented on a change in pull request #10073:
URL: https://github.com/apache/arrow/pull/10073#discussion_r615649844
##########
File path: rust/arrow/src/compute/kernels/concat.rs
##########
@@ -384,4 +384,51 @@ mod tests {
Ok(())
}
+
+ fn collect_string_dictionary(
+ dictionary: &DictionaryArray<Int32Type>,
+ ) -> Vec<Option<String>> {
+ let values = dictionary.values();
+ let values = values.as_any().downcast_ref::<StringArray>().unwrap();
+
+ (0..dictionary.len())
+ .map(move |i| match dictionary.keys().is_valid(i) {
+ true => {
+ let key = dictionary.keys().value(i);
+ Some(values.value(key as _).to_string())
+ }
+ false => None,
+ })
+ .collect()
+ }
+
+ #[test]
+ fn test_string_dictionary_array() -> Result<()> {
+ let input_1: DictionaryArray<Int32Type> =
+ vec!["hello", "A", "B", "hello", "hello", "C"]
+ .into_iter()
+ .collect();
+ let input_2: DictionaryArray<Int32Type> =
+ vec!["hello", "E", "E", "hello", "F", "E"]
+ .into_iter()
+ .collect();
+
+ let concat = concat(&[&input_1 as _, &input_2 as _]).unwrap();
+ let concat = concat
+ .as_any()
+ .downcast_ref::<DictionaryArray<Int32Type>>()
+ .unwrap();
+
Review comment:
I'm confused, is this not what I do a couple of lines down?
Edit: I've taken a guess at what you meant and hardcoded the expected result
instead of computing it
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]