unikdahal opened a new pull request, #24582:
URL: https://github.com/apache/datafusion/pull/24582

   ## Which issue does this PR close?
   
   Closes #24581.
   
   ## Rationale for this change
   
   `StructArray::new` panics for structs with zero fields because it cannot 
infer array length from an empty column list. This hit two code paths in 
`ScalarValue`: `new_default` when building a default value for a zero-field 
struct type, and `compact_view_buffers` (used by `ScalarValue::compact`) when 
compacting a struct array that has zero fields but a nonzero row count.
   
   ## What changes are included in this PR?
   
   - `ScalarValue::new_default` and `compact_view_buffers` now special-case 
zero-field structs, using `StructArray::new_empty_fields` (which takes an 
explicit length/nulls instead of inferring it from columns) rather than 
`StructArray::new`.
   - Added `test_compact_empty_struct` covering the panic case.
   
   ## Are these changes tested?
   
   Yes, new unit test added.
   
   ## Are there any user-facing changes?
   
   No behavior change other than fixing a panic on empty-field structs.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to