bjchambers commented on issue #1657:
URL: https://github.com/apache/arrow-rs/issues/1657#issuecomment-1119731242

   I'm also seeing this with `new_null_array(&DataType::Struct(vec![]), N)`. I 
wonder if the best path would be the following:
   
   1. Introduce a method on `StructArray` `fn new(data_type: &DataType, length: 
usize, fields: Vec<(Field, ArrayRef)>) -> Self` which just checks that all the 
field arrays have the given `length`. This could also have a variant that takes 
the null `Buffer`.
   2. The existing `StructArray::from(...)` methods use that based off the 
length of the first field (throwing a reasonable error when called with 
0-fields.
   3. The `new_null_array` can then use that method rather to ensure that it 
works even on zero length arrays.
   
   Then users who have to handle the non-zero length array of 0 fields would be 
able to call `StructArray::new(...)` explicitly.


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to