ethan-tyler commented on code in PR #9220:
URL: https://github.com/apache/arrow-rs/pull/9220#discussion_r2709423316
##########
arrow-cast/src/cast/mod.rs:
##########
@@ -5579,6 +5579,293 @@ mod tests {
assert_eq!(dict_array.values().len(), 3);
}
+ #[test]
+ fn test_cast_string_array_to_dict_utf8_view() {
+ let array = StringArray::from(vec![Some("one"), None, Some("three"),
Some("one")]);
+
+ let cast_type =
+ DataType::Dictionary(Box::new(DataType::UInt16),
Box::new(DataType::Utf8View));
+ let cast_array = cast(&array, &cast_type).unwrap();
+ assert_eq!(cast_array.data_type(), &cast_type);
+ assert_eq!(
Review Comment:
Good catch. `array_to_strings` explicitly sets `.with_null("null")`
(`:8507-8512`), `None` and `Some("null")` both render as `"null"` in test
output.
The cast itself is correct - nulls are preserved as nulls. For string casts
this happens via `builder.append_null()` in `string.rs:21-37`. For
dictionary-to-string it's via `unpack_dictionary` and `take` in
`dictionary.rs:145-152`. The collision is in the test formatter, not the cast
result.
Will update dictionary-cast tests to assert semantics directly and add a
regression case with both a real null and a literal `"null"` string to confirm
we're testing the array.
--
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]