Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StructArray::try_new behavior can be unexpected when there are no child arrays #7246

Open
westonpace opened this issue Mar 6, 2025 · 0 comments · May be fixed by #7247
Open

StructArray::try_new behavior can be unexpected when there are no child arrays #7246

westonpace opened this issue Mar 6, 2025 · 0 comments · May be fixed by #7247
Labels
enhancement Any new improvement worthy of a entry in the changelog

Comments

@westonpace
Copy link
Member

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
When a struct array is created with StructArray::try_new we determine the length based on the length of the first child array. If there are no child arrays then we infer a length of 0. Users can use StructArray::new_empty_fields to specify the length. This is perfectly valid but it has led to bugs. For example #7224

Describe the solution you'd like
We should return an error in StructArray::try_new if there are no child arrays provided and direct the user to call StructArray::new_empty_fields instead.

Describe alternatives you've considered
We can live with the status quo. It isn't wrong, just easy for bugs.

Additional context
This would be a breaking change.

@westonpace westonpace added the enhancement Any new improvement worthy of a entry in the changelog label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant