dhruvxvaishnav opened a new pull request, #10726:
URL: https://github.com/apache/arrow-rs/pull/10726

   # Which issue does this PR close?
   
   - Closes #10711
   
   # Rationale for this change
   
   When casting with \safe: false\, errors were raised for invalid values even 
if those values were masked by nulls in the array's null bitmap or child 
offsets (e.g. invalid UTF-8 in a null binary slot, invalid castable child items 
in a null fixed-size list, list, list view, struct, or map). Because masked 
values are logically null, the cast should succeed and preserve the null mask.
   
   # What changes are included in this PR?
   
   - \rrow-cast/src/cast/string.rs\: In \cast_binary_to_string\ and 
\cast_binary_view_to_string_view\, if fast-path UTF-8 conversion fails with 
\safe: false\ and the array contains nulls, only validate non-null values for 
valid UTF-8.
   - \rrow-cast/src/cast/list.rs\: Propagate parent list nulls to child arrays 
before casting in \cast_single_element_fixed_size_list_to_values\, 
\cast_list_values\, \cast_list_view_values\, \cast_list\, \cast_list_view\, and 
\cast_list_to_list_view\ when the target field is nullable.
   - \rrow-cast/src/cast/mod.rs\: Propagate parent nulls for \FixedSizeList\ 
and \StructArray\ columns before calling \cast_with_options\ when the target 
field is nullable.
   - \rrow-cast/src/cast/map.rs\: Propagate parent nulls to map key and value 
child arrays when target fields are nullable.
   - Added comprehensive unit tests in \rrow-cast\ covering all container 
types and binary-to-string casts with masked null values.
   
   # Are these changes tested?
   
   Yes, new unit tests added in \rrow-cast/src/cast/mod.rs\:
   - \  est_binary_to_string_unsafe_masked_nulls\
   - \  est_binary_view_to_string_view_unsafe_masked_nulls\
   - \  est_fixed_size_list_unsafe_masked_nulls\
   - \  est_list_unsafe_masked_nulls\
   - \  est_list_view_unsafe_masked_nulls\
   - \  est_struct_unsafe_masked_nulls\
   - \  est_map_unsafe_masked_nulls\
   
   All tests and lints run and pass cleanly:
   - \cargo test -p arrow-cast\
   - \cargo +stable fmt --all -- --check\
   - \cargo clippy -p arrow-cast --all-targets --all-features -- -D warnings\
   - \git diff --check\
   
   # Are there any user-facing changes?
   
   No breaking changes to public APIs. \safe: false\ casting now correctly 
succeeds on arrays where unconvertible values are masked by nulls instead of 
erroneously failing.


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

Reply via email to