Repository navigation
GH-830: Create Null children when building a struct writer from a Field #1379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
743b7d7
edf274a
6e9d1a3
8fb9a80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,7 +164,7 @@ public enum MinorType { | |
| @Override | ||
| public FieldVector getNewVector( | ||
| Field field, BufferAllocator allocator, CallBack schemaChangeCallback) { | ||
| return new NullVector(field.getName()); | ||
| return new NullVector(field); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes a That breaks code that worked before. Schema schema = new Schema(List.of(
new Field("n", FieldType.notNullable(ArrowType.Null.INSTANCE), null)));
try (VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator);
VectorSchemaRoot target = VectorSchemaRoot.create(schema, allocator)) {
root.setRowCount(3);
try (VectorSchemaRoot slice = root.slice(0, 2)) {
VectorSchemaRootAppender.append(target, slice);
}
}Before this PR, both sides were nullable, so this worked. Could you also update @Override
public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
return new TransferImpl(new NullVector(ref, field.getFieldType()));
}
@Override
public TransferPair getTransferPair(Field field, BufferAllocator allocator) {
return new TransferImpl(new NullVector(field));
}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, thanks. In 8fb9a80 |
||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addVectorAsNullableis lost further down:addOrGet->FieldType.createNewSingleVector->MinorType.NULL.getNewVector, which returnsnew NullVector(field.getName()). That always gives a nullable field with no metadata. So for a child likeField("n", FieldType.notNullable(ArrowType.Null.INSTANCE), null), the struct field doesn't match the input field.Could we change
Types.java(line 167) toreturn new NullVector(field);and pass the child ownFieldTypehere? That keeps both nullability and metadata. It also fixesField.createVector, which goes through the samegetNewVector.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in edf274a:
StructWritersnow passeschild.getFieldType(), andTypes.NULL.getNewVectorusesnew NullVector(field)so nullability and metadata surviveaddOrGet/Field.createVector.TestStructVector(netty + unsafe): 15 tests, 0 failures.