Skip to content

[Java] StructVector throws with ExtensionType #87

@FiV0

Description

@FiV0

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

Currently when creating a struct vector with a child being an extension type things throw:

  @Test
  public void testStructVectorWithExtensionTypes() {
    TestExtensionType.UuidType uuidType = new TestExtensionType.UuidType();
    Field uuidField =  new Field("struct_child", FieldType.nullable(uuidType), null);
    Field structField = new Field("struct", FieldType.nullable(new ArrowType.Struct()), List.of(uuidField));
    // throws
    StructVector s1 = new StructVector(structField, allocator, null);
    // doesn't throw
    StructVector s2 = (StructVector) structField.createVector(allocator);
    s1.close();
    s2.close();
  }

I am mainly running into this while trying to create a TransferPair.

  @Test
  public void testStructVectorTransferPairWithExtensionType() {
    TestExtensionType.UuidType uuidType = new TestExtensionType.UuidType();
    Field uuidField =  new Field("uuid_child", FieldType.nullable(uuidType), null);
    Field structField = new Field("struct", FieldType.nullable(new ArrowType.Struct()), List.of(uuidField));

    StructVector s1 = (StructVector) structField.createVector(allocator);
    TestExtensionType.UuidVector uuidVector = s1.addOrGet("uuid_child", FieldType.nullable(uuidType), TestExtensionType.UuidVector.class);
    s1.setValueCount(1);
    uuidVector.set(0, new UUID(1, 2));
    s1.setIndexDefined(0);

    TransferPair tp = s1.getTransferPair(structField, allocator);
    final StructVector toVector = (StructVector) tp.getTo();
    assertEquals(s1.getField(), toVector.getField());
    assertEquals(s1.getField().getChildren().get(0), toVector.getField().getChildren().get(0));
    // also fails but probably another issue
//    assertEquals(s1.getValueCount(), toVector.getValueCount());
//    assertEquals(s1, toVector);

    s1.close();
    toVector.close();
  }

Component(s)

Java

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions