You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/05 23:13:22 UTC

[GitHub] [arrow-rs] bjchambers opened a new issue, #1657: StructArray::from panics when passed empty vector

bjchambers opened a new issue, #1657:
URL: https://github.com/apache/arrow-rs/issues/1657

   **Describe the bug**
   `StructArray::from(vec![])` causes a panic because it tries to index into the list of arrays to check their lengths here https://github.com/apache/arrow-rs/blob/master/arrow/src/array/array_struct.rs#L212.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   
   **Expected behavior**
   A clear and concise description of what you expected to happen.
   
   **Additional context**
   Add any other context about the problem here.
   


-- 
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-unsubscribe@arrow.apache.org.apache.org

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


[GitHub] [arrow-rs] bjchambers commented on issue #1657: StructArray::from panics when passed empty vector

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on issue #1657: StructArray::from panics when passed empty vector

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #1657:
URL: https://github.com/apache/arrow-rs/issues/1657#issuecomment-1119325132

   I think having it just create a 0 length array would be sensible and avoid surprise panics. There are niche use-cases where a non-zero row count may be desirable, see #1536, but I think we can deal with that as needed?


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on issue #1657: StructArray::from panics when passed empty vector

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #1657:
URL: https://github.com/apache/arrow-rs/issues/1657#issuecomment-1572203701

   I think this is closed by #4064 


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] bjchambers commented on issue #1657: StructArray::from panics when passed empty vector

Posted by GitBox <gi...@apache.org>.
bjchambers commented on issue #1657:
URL: https://github.com/apache/arrow-rs/issues/1657#issuecomment-1119771466

   I think the issue with just creating it of length `0` is that if you then go to put that into a record batch or enclosing struct array of a given length you'll have problems because the lengths don't line up. So, it seems like general idea of having a constructor from an explicit length makes sense, and then the various `from` methods can use that.


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold closed issue #1657: StructArray::from panics when passed empty vector

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #1657: StructArray::from panics when passed empty vector
URL: https://github.com/apache/arrow-rs/issues/1657


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] bjchambers commented on issue #1657: StructArray::from panics when passed empty vector

Posted by GitBox <gi...@apache.org>.
bjchambers commented on issue #1657:
URL: https://github.com/apache/arrow-rs/issues/1657#issuecomment-1119192344

   I guess perhaps this is reasonable, since without their being at least one array it would be impossible to know the length of the struct array to create.


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on issue #1657: StructArray::from panics when passed empty vector

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #1657:
URL: https://github.com/apache/arrow-rs/issues/1657#issuecomment-1119750878

   I think you could get away with a simpler signature, such as
   
   ```
   StructArray::new_with_len(fields: Vec<(Field, ArrayRef)>, len: usize) -> Self
   ```
   
   But yes that makes sense to me, I hadn't thought of the null use-case


-- 
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-unsubscribe@arrow.apache.org

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