You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2025/03/04 07:21:39 UTC
[I] Nullability in schema is not considered in VectorLoader [arrow-java]
viirya opened a new issue, #648:
URL: https://github.com/apache/arrow-java/issues/648
### Describe the bug, including details regarding any error messages, version, and platform.
We hit an issue on using `VectorLoader` to load some Arrow vectors.
```
java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:970)
at org.apache.arrow.vector.VectorLoader.loadBuffers(VectorLoader.java:104)
at org.apache.arrow.vector.VectorLoader.load(VectorLoader.java:84)
```
The schema of the `VectorSchemaRoot` is `Schema<_0: Utf8 not null>`.
The field vector in the root is `Utf8` type, not nullable. As it is `Utf8` type, `TypeLayout.getTypeBufferCount` reports buffer count 3 for it.
The IPC `ArrowRecordBatch` message to load has one node: `ArrowFieldNode [length=1500, nullCount=0]`, and two buffers:
```
buffer: ArrowBuf[...], address:....., capacity:..., ArrowBuf
buffer: ArrowBuf[...], address:....., capacity:..., ArrowBuf
```
So when `VectorLoader.loadBuffers` is trying to load buffers by iterating the buffer list, it assumes there are 3 buffers but actually there are only 2 buffers (null buffer doesn't exist). That's why it hits `NoSuchElementException`.
I think that an array that in the spec can contain a null bitmap may choose to not allocate the validity buffer (also see the [doc](https://arrow.apache.org/docs/format/Columnar.html#validity-bitmaps)). So the `Utf8` array with 2 buffers is correct by the spec. The issue looks like that `VectorLoader` doesn't consider field nullability when loading buffers.
We uses Arrow Java 15.0.2 version. But as I just looked at the current code in this repo, looks like current `TypeLayout` has this issue still.
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya closed issue #648: Nullability in schema is not considered in VectorLoader
URL: https://github.com/apache/arrow-java/issues/648
--
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: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696527973
Field nullability is irrelevant: it's the actual number of nulls that matters. A nullable vector may still contain no nulls and this case should still apply.
```
/// The number of observed nulls. Fields with null_count == 0 may choose not
/// to write their physical validity bitmap out as a materialized buffer,
/// instead setting the length of the bitmap buffer to 0.
null_count: long;
```
It seems that the problem is more that the code loading the buffers should be inserting a zero-length (or possibly null) buffer where the nullability buffer would have gone so that expectations line up.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696461931
I will open a PR soon.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696630912
Oh, the error case could be improved than an exception like current one, though. I will open a small PR for it. Sounds good?
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696611970
AIUI, yes, there still needs to be an entry in the list of buffers in the Flatbuffer metadata, even if there is no memory allocated.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696622453
Though, from the exception, it seems actually the issue is that there's more entries than buffers, not the other way around?
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696529758
(Also, note that nothing really validates field nullability so it is very possible to have a non-nullable field and yet still have nulls in the data; IPC code shouldn't rely on field nullability ever IMO.)
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696621157
Yeah, so seems the issue is that we don't put the entry in the message. The code is not from me. So I may need to take more looks. Thanks for confirming it.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696625611
There are 2 entries in the messages for the data and offset. The null buffer is not.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696564758
> Field nullability is irrelevant: it's the actual number of nulls that matters. A nullable vector may still contain no nulls and this case should still apply.
Oh, yes, that's correct. It is not due to the field nullability but actually the null count in the vector. My description is not accurate.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696600118
Hmm, after re-thinking it, I wonder if this is a bug actually? Although in the physical memory layout of an array, the null buffer may not be allocated, however, as the message to load is an ipc `RecordBatch` message, maybe the null buffer cannot be ignored in the message? I.e., at least it needs to be an empty one? If so, then the issue maybe due to the incorrect message produced by somewhere in our code (it seems not from Arrow Java).
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696625091
Ah, I see now - there's not an entry, so there's not a buffer generated, and VectorLoader iterates based on fixed knowledge of the type layout, ignoring the entries? In that case yes I think the Java library is right, albeit not very clear about what went wrong.
--
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
Re: [I] Nullability in schema is not considered in VectorLoader [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #648:
URL: https://github.com/apache/arrow-java/issues/648#issuecomment-2696633261
That would be appreciated, yes!
--
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