apache / apache/arrow-java

'Unknown type: NULL' when initialising a NullableStructWriter from a struct with NullVector children

Open
#830 0 comments 0 reactions 0 assignees View on GitHub
Type: bug
Dominant language
Java
Stars
94
Forks
152
Avg merge
3d 16h
Merged PRs (30d)
11

Description

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

added test case to TestStructVector:

```java

@Test
public void testStructVectorTransferPairWithNullType() {
Field uuidField = new Field("null", FieldType.nullable(ArrowType.Null.INSTANCE), null);
Field structField =
new Field("struct", FieldType.nullable(new ArrowType.Struct()), List.of(uuidField));

try(StructVector s1 = (StructVector) structField.createVector(allocator)) {
NullVector nullVector =
s1.addOrGet("null", FieldType.nullable(ArrowType.Null.INSTANCE), NullVector.class);
s1.setValueCount(1);
nullVector.setNull(0);
s1.setIndexDefined(0);

TransferPair tp = s1.getTransferPair(structField, allocator);
try (StructVector toVector = (StructVector) tp.getTo()) {
assertEquals(s1.getField(), toVector.getField());
}
}
}
```

got this:

```
java.lang.UnsupportedOperationException: Unknown type: NULL
at org.apache.arrow.vector.complex.impl.NullableStructWriter.(NullableStructWriter.java:279)
at org.apache.arrow.vector.complex.StructVector.(StructVector.java:74)
at org.apache.arrow.vector.complex.StructVector.getTransferPair(StructVector.java:261)
at org.apache.arrow.vector.TestStructVector.testStructVectorTransferPairWithNullType(TestStructVector.java:389)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
```

expected: similar result to `testStructVectorTransferPairWithExtensionType`

Cheers!

James

our issue: xtdb/xtdb#4693

Contributor guide

Open the contributing guide

Research direction

Start with TestStructVector.testStructVectorTransferPairWithNullType and compare it with testStructVectorTransferPairWithExtensionType. Trace StructVector.getTransferPair into StructVector.java and NullableStructWriter.java, then run the focused TestStructVector tests; done when a struct containing a NullVector transfers without the Unknown type: NULL exception and the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.