felipecrv opened a new pull request, #37202:
URL: https://github.com/apache/arrow/pull/37202
### Rationale for this change
The layout constraint checks in `GetArrayView` are too strict when they
don't allow non-nullable STRUCT fields to be null since STRUCT fields can
legally have any value when the parent `Array` describes the entry as not valid.
Reproduction script
```python
import pyarrow as pa
struct_type = pa.struct([pa.field("x", pa.int32(), nullable=False)])
nulls = pa.nulls(5, struct_type)
# The following is an error:
nulls.cast(struct_type)
```
### What changes are included in this PR?
Allow the execution of `GetArrayView` with nulls in non-nullable fields iff
the parent `Array` is 100% null. To cover all cases, the checks would have to
be done value by value, but that would be expensive. This PR covers the cases
where STRUCT arrays are created by `MakeArrayOfNull`. Kernels producing STRUCTs
with a few nulls might be wiser to set validity bits to 1 on non-nullable
fields even when the parent is null.
### Are these changes tested?
By existing tests and manual reproduction script.
--
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]