-
Notifications
You must be signed in to change notification settings - Fork 925
Compute data buffer length by using start and end values in offset buffer #5741
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
Conversation
There are comments a few lines above the changes about the len of the data buffer, which should probably be updated. Other than that the change looks good to me, for slices of StringArray/BinaryArray the first offset would be != 0. |
Thank you @jhorstmann. I've updated the code comment. |
Hmm, our CI pipeline (Archery test With other arrows) seems broken:
Created #5742 |
The Ci failure is covered by #5719 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to write a test for this fix? Otherwise I worry we may end up breaking it in future releases without knowing
I added a unit test that simulates an empty string array with a non-zero offset from a producer and checks the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me -- thank you @viirya and @jhorstmann
Merged. Thanks @jhorstmann @alamb |
This PR breaks handling of non-empty arrays, in particular consider the case of a sliced offset buffer consisting of |
Proposed fix in #5964 |
Yea, this copied how to calculate the length of data buffer from Arrow Java and it is incorrect. |
Which issue does this PR close?
Closes #5756.
Rationale for this change
Encountered an issue when importing empty variable-size binary layout array (e.g., string) from Java Arrow.
There is difference between Java Arrow and arrow-rs when computing the length of data buffer: apache/arrow#41610 (comment)
This is how Java Arrow imports an Utf8 array:
So even the offset buffer is not initialized, for empty array with one element offset buffer,
end - start
is always 0 that is the length of data buffer. That is why the added roundtrip tests are passed.But in arrow-rs, it takes the last value of the offset buffer as the length of data buffer, i.e.,
end
. If the value is not initialized to zero, the computed length of data buffer is incorrect.That is what I found for the first offset value from the spec:
It looks like the first value doesn't have to be 0, although generally it is. So seems Java Arrow's approach is (more) correct.
What changes are included in this PR?
Changing the way to compute the length of data buffer when importing an empty variable-size binary layout array.
Are there any user-facing changes?
No