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

   ### Rationale for this change
   
   `StructArray::GetFlattenedField` always sets `buffers[0]` on the flattened 
child. Union and run-end encoded arrays ca
   nnot carry a validity bitmap, so flattening a struct with a sparse union 
child hits a `ARROW_CHECK` in `SparseUnionAr
   ray::SetData` and aborts the process, and a run-end encoded child produces 
an invalid array whose struct-level nulls
   are silently lost. This affects `StructArray.flatten()`, 
`RecordBatch.from_struct_array()` and the `struct_field` ker
   nel.
   
   ### What changes are included in this PR?
   
   For children whose type cannot have a validity bitmap, `GetFlattenedField` 
returns the (sliced) child unchanged when
   the struct has no nulls in the range, and returns `NotImplemented` when it 
does. Propagating struct nulls into union
   or run-end encoded children would need their data rewritten, which is left 
out of this fix.
   
   ### Are these changes tested?
   
   Yes. `StructArray.FlattenChildWithoutValidityBitmap` covers run-end encoded, 
sparse union and dense union children, w
   ith no struct nulls, with a slice that excludes the null row, and with 
struct nulls. It fails without the fix and pas
   ses with it; the full `arrow-array-test` suite passes locally.
   
   ### Are there any user-facing changes?
   
   Flattening a struct with nulls whose child is a union or run-end encoded 
array now raises `NotImplemented` instead of
    aborting the process or returning an invalid array.
   
   **This PR contains a "Critical Fix".** Without it, flattening such a struct 
either crashes the process (sparse union
   child) or produces an invalid array that drops the struct's nulls (run-end 
encoded child).
   
   ### Was AI used for this PR?
   
   In accordance to the [AI generation 
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generat
   ed-code), please disclose below whether and how AI was used in this PR.
   
   **PR code and description written by:**
   
   - [ ] Human
   - [ ] AI
   
   **Reviewed before submission by:**
   
   - [ ] Human
   - [ ] AI
   - [ ] Not reviewed
   
   * GitHub Issue: #55958


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