Skip to content

Commit

Permalink
ARROW-1347: [JAVA] Return consistent child field name for List Vectors
Browse files Browse the repository at this point in the history
This makes the child fields of ListVector have consistent names of `ListVector.DATA_VECTOR_NAME`. Previously, an empty ListVector would have a child name of `ZeroVector.name` which is "[DEFAULT]".

Author: Bryan Cutler <cutlerb@gmail.com>
Author: Steven Phillips <steven@dremio.com>

Closes apache#1119 from BryanCutler/java-ListVector-child-name-ARROW-1347 and squashes the following commits:

c240378 [Bryan Cutler] changed to use instanceof and added test
2923a45 [Steven Phillips] ARROW-1347: [JAVA] return consistent child field name for List vectors
  • Loading branch information
BryanCutler authored and Yuliya Feldman committed Oct 10, 2017
1 parent f2596dd commit 0c1042e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.arrow.vector.schema.ArrowFieldNode;
import org.apache.arrow.vector.types.Types.MinorType;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.ArrowType.Null;
import org.apache.arrow.vector.types.pojo.DictionaryEncoding;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
Expand Down Expand Up @@ -296,6 +297,9 @@ public int getBufferSize() {

@Override
public Field getField() {
if (getDataVector() instanceof ZeroVector) {
return new Field(name, fieldType, ImmutableList.of(new Field(DATA_VECTOR_NAME, FieldType.nullable(Null.INSTANCE), null)));
}
return new Field(name, fieldType, ImmutableList.of(getDataVector().getField()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,16 @@ public void testCopyFrom() throws Exception {
Assert.assertTrue("shouldn't be null", reader.isSet());
}
}

@Test
public void testConsistentChildName() throws Exception {
try (ListVector listVector = ListVector.empty("sourceVector", allocator)) {
String emptyListStr = listVector.getField().toString();
assertTrue(emptyListStr.contains(ListVector.DATA_VECTOR_NAME));

listVector.addOrGetVector(FieldType.nullable(MinorType.INT.getType()));
String emptyVectorStr = listVector.getField().toString();
assertTrue(emptyVectorStr.contains(ListVector.DATA_VECTOR_NAME));
}
}
}

0 comments on commit 0c1042e

Please sign in to comment.