Skip to content

[Java] AIOOBE trying to splitAndTransfer DUV within nullable struct #40999

@jarohen

Description

@jarohen

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

If a DenseUnionVector is contained within a nullable StructVector, and that struct has nullable entries, trying to splitAndTransfer fails with an ArrayIndexOutOfBoundsException.

Within a struct vector, if an entry is null, then the entries in its children vectors are undefined, so DUV cannot always expect typeId >= 0, and should guard against it where necessary.

Test case:

  @Test
  public void testSplitAndTransferDuvInStruct() {
    try (StructVector struct = StructVector.empty("struct", allocator)) {
      DenseUnionVector duv = struct.addOrGet("duv",
          FieldType.notNullable(MinorType.DENSEUNION.getType()),
          DenseUnionVector.class);
      byte i32TypeId = duv.registerNewTypeId(Field.notNullable("i32", MinorType.INT.getType()));
      duv.addVector(i32TypeId, new IntVector("i32", allocator));

      struct.setIndexDefined(0);
      duv.setTypeId(0, i32TypeId);
      duv.setSafe(0, newIntHolder(42));

      struct.setNull(1);
      struct.setValueCount(2);

      try (StructVector dest = StructVector.empty("dest", allocator)) {
        TransferPair pair = struct.makeTransferPair(dest);
        pair.splitAndTransfer(0, 2);

        assertEquals(2, dest.getValueCount());
        assertFalse(dest.isNull(0));
        assertEquals(42, dest.getObject(0).get("duv"));
        assertTrue(dest.isNull(1));
      }
    }
  }

(PR incoming)

Component(s)

Java

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions