Skip to content

StructArray take returns incorrect length with empty fields #6732

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

Closed
gatesn opened this issue Nov 14, 2024 · 1 comment · Fixed by #7224
Closed

StructArray take returns incorrect length with empty fields #6732

gatesn opened this issue Nov 14, 2024 · 1 comment · Fixed by #7224
Labels

Comments

@gatesn
Copy link

gatesn commented Nov 14, 2024

Describe the bug
Calling compute::take on a struct array with zero fields results in an array with length == 0, regardless of the length of the take array.

Expected behavior
The result should be a struct array with no fields and length == take_indices.len()

Additional context
In my own code I've found it too easy to drop struct array lengths. I wonder if it's worth:

  • Adding StructArray::try_new(fields, arrays, nulls, length)
  • Making StructArray::try_new(fields, arrays, nulls) return an error for empty fields instead of picking a default length
@westonpace
Copy link
Member

Adding StructArray::try_new(fields, arrays, nulls, length)
Making StructArray::try_new(fields, arrays, nulls) return an error for empty fields instead of picking a default length

I like these ideas and have made a proposal in #7247 . There is some discussion on also just changing the signature of try_new (instead of adding a new method) which would be more explicitly breaking but more likely to help others catch the error. Feel free to weigh in if you feel strongly about the approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants