connorsimms opened a new pull request, #50502:
URL: https://github.com/apache/arrow/pull/50502

   Resolves #37004 
   ### Rationale for this change
   `table.cast(table.schema)` errored or segfaulted when the schema contained a 
struct with an extension-typed field whose storage is a list. 
   
   This cast takes a zero-copy view, and `ViewDataImpl::MakeDataView` found 
children using `type->fields()`, which is never populated for extension types 
since their structure is in `storage_type()`. The same issue exists in 
`AccumulateLayouts`. The storage's child data gets dropped and leaves an 
invalid array that downstream code throws/crashes on.
   
   This bug is similar to #37669, except that the fix for #37669 addressed 
casting *to* an extension with nested storage but not this particular 
struct-wrapped view path.
   
   ### What changes are included in this PR?
   - `cpp/src/arrow/array/data.cc` - `AccumulateLayouts` and 
`ViewDataImpl::MakeDataView` now recurse into `storage_type()->fields()` for 
`ExtensionType`, instead of the extension type's empty `fields()`.
   - `cpp/src/arrow/array/array_view_test.cc`
   - `python/pyarrow/tests/test_extension_type.py`
   ### Are these changes tested?
   Yes,
   - `cpp/src/arrow/array/array_view_test.cc` - Two tests for viewing an 
extension array with nested storage for fixed-size and variable-size lists.
   - `python/pyarrow/tests/test_extension_type.py` - A test casting a table / 
struct containing an extension type with list-based storage to its own schema.
   - Also, all reproducers from the linked issue were checked against this fix, 
including the segfault case.
   ### Are there any user-facing changes?
   No API changes. Operations that previously raised errors or crashed relating 
to casting/viewing a struct or table with an extension type with nested storage 
now succeed.
   
   **This PR contains a "Critical Fix".** It fixes a bug that could produce 
invalid arrays and on certain code paths cause segfaults.
   


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