Weijun-H commented on code in PR #8173:
URL: https://github.com/apache/arrow-rs/pull/8173#discussion_r2288040264
##########
parquet-variant-compute/src/cast_to_variant.rs:
##########
@@ -1820,6 +1841,43 @@ mod tests {
);
}
+ #[test]
+ fn test_cast_to_variant_dictionary() {
+ let values = StringArray::from(vec!["apple", "banana", "cherry",
"date"]);
+ let keys = Int32Array::from(vec![Some(0), Some(1), None, Some(2),
Some(0), Some(3)]);
+ let dict_array = DictionaryArray::<Int32Type>::try_new(keys,
Arc::new(values)).unwrap();
+
+ run_test(
+ Arc::new(dict_array),
+ vec![
+ Some(Variant::from("apple")),
+ Some(Variant::from("banana")),
+ None,
+ Some(Variant::from("cherry")),
+ Some(Variant::from("apple")),
+ Some(Variant::from("date")),
+ ],
+ );
+ }
+
+ #[test]
+ fn test_cast_to_variant_dictionary_with_nulls() {
+ // Test dictionary with null values in the values array
+ let values = StringArray::from(vec![Some("a"), None, Some("c")]);
+ let keys = Int8Array::from(vec![Some(0), Some(1), Some(2), Some(0)]);
+ let dict_array = DictionaryArray::<Int8Type>::try_new(keys,
Arc::new(values)).unwrap();
+
+ run_test(
+ Arc::new(dict_array),
+ vec![
+ Some(Variant::from("a")),
+ None, // key 1 points to null value
+ Some(Variant::from("c")),
+ Some(Variant::from("a")),
+ ],
+ );
+ }
Review Comment:
It only contains the `value`. What about the `key` in the `Dictionary`?
--
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]