liamzwbao commented on code in PR #8173:
URL: https://github.com/apache/arrow-rs/pull/8173#discussion_r2288946739
##########
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:
I may misunderstand the behavior. There's no corresponding datatype in
Variant so what I did is to unfold the dictionary encoding and return the logic
array it represent.
Do you mean we need to represent the same internal structure of the
dictionary encoding in variant?
--
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]