-
Notifications
You must be signed in to change notification settings - Fork 105
GH-586: Override fixedSizeBinary method for UnionMapWriter #885
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
This comment has been minimized.
This comment has been minimized.
Hm, looks like I don't have enough permissions to add labels. Could the maintainers add the |
|
Hi @nbauernfeind! It's my attempt to address the issue you opened. Could you please take a look? Is it what you had in mind for it? |
|
@axreldable sure. I will. FYI we are working on fixing the CI right now. Your PR will probably need a rebase as soon as CI is green again. I will keep you posted. |
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.
I suppose it technically works but I find it very confusing to recycle the test, especially since the map value was always BigInt before. I'd rather see a new test that exercises both the key/value paths explicitly and is explicitly marked as a regression test.
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.
@lidavidm , thank you for looking into it! Sorry for the confusion. Let me introduce a separate unit test.
--
Could you please clarify what do you mean by
explicitly marked as a regression test
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.
/** Regression test for https://github.com/apache/arrow-java/issues/586 */
@Test
void mapFixedSizeBinary() {
// ...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.
@lidavidm , I've implemented a separate unit test for fixedSizeBinary.
However, I came across an issue. When I call writer.key().fixedSizeBinary() for the first time, it fails with NPE, as it falls back to NullableStructWriter which requires writer to be not-null (checkout the testFixedSizeBinaryWriterInitializationError test).
It work when I first initialize writers for both key and value fields with other writes, e.g. bigInt (checkout testFixedSizeBinaryWriter test).
Could you help me here? What would be the right way to initialize writes for key and value fields for the UnionMapWriter?
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.
@lidavidm , I introduced public FixedSizeBinaryWriter fixedSizeBinary(int byteWidth) in the UnionMapWriter which supposed to be used for initialization of the key and value writers. I’d really appreciate your feedback if there’s a better approach.
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.
Sorry, I'm rather behind - I will try to review this soon but I can't make any promises right now
lidavidm
left a comment
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.
LGTM. @jbonofre?
|
@lidavidm , thank you for the approval! I added |
|
I also noticed one more thing here. It's possible to add a map with It doesn't relate to the change as I can do the same for other types, e.g. for the So, maybe it’s worth creating an issue about it. Or let me know if it’s expected. |
|
@axreldable sorry for the delay. It would be worth making an issue, however, as far as I understand, the APIs were originally designed not to do very much checking, instead assuming that you maintain the needed invariants. (For instance: I don't think anything stops you from putting nulls in a non-null column.) |
What's Changed
UnionMapWriterwill null out the entire map struct entry instead of setting the value to null in:This PR overrides the
fixedSizeBinary()method for theUnionMapWriter, resolving it.In addition, it introduces the
fixedSizeBinary(int byteWidth)which needs to be used to initializekeyandvaluewrites inUnionMapWriterif they have not been initialized.Closes #586.