Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/ai/chalk/internal/arrow/Unmarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,14 @@ private static Object primitiveToRich(
) throws Exception {
var fieldType = meta.field().getType();
if (meta.isList()) {
Feature<?> newFeature = new Feature<>();
if (primitiveVal == null) {
newFeature.setValue(null);
return newFeature;
}

List<?> primitiveList = (List<?>) primitiveVal;
NamespaceMemoItem currMemo = allMemo.get(meta.listUnderlyingClass());
Feature<?> newFeature = new Feature<>();

if (currMemo == null) {
// Not a struct or features class, since it's not in the memo
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/ai/chalk/arrow/TestUnmarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ai.chalk.internal.Utils;
import ai.chalk.internal.arrow.FeatherProcessor;
import ai.chalk.internal.arrow.Unmarshaller;
import ai.chalk.models.OnlineQueryResult;
import org.apache.arrow.memory.ArrowBuf;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.*;
Expand Down Expand Up @@ -1459,6 +1460,36 @@ public void TestSnakeCaseBackCompat() throws Exception {
assert namedClasses[2].abc_7d7_efg.getValue().equals("c");
}

@Test
public void testUnmarshalOnlineQueryResultWithNullableNestedStructList() throws Exception {
var localAllocator = new RootAllocator(FeatherProcessor.ALLOCATOR_SIZE_TEST);
var structVector = StructVector.empty("arrow_user.favorite_struct_complex", localAllocator);
structVector.allocateNew();

var structWriter = structVector.getWriter();
var goodNumberWriter = structWriter.bigInt("good_number");
// Creating the child field without writing any entries leaves this nested list null.
structWriter.list("good_dataclasses");

structWriter.start();
goodNumberWriter.writeBigInt(42L);
structWriter.end();

structVector.setValueCount(1);
var root = VectorSchemaRoot.of(structVector);
root.setRowCount(1);
var table = new Table(root);
try (var result = new OnlineQueryResult(table, Map.of(), null, null, localAllocator)) {
var users = result.unmarshal(ArrowUser.class);

assert users.length == 1;
assert users[0].favoriteStructComplex != null;
assert users[0].favoriteStructComplex.goodNumber.getValue().equals(42L);
assert users[0].favoriteStructComplex.goodDataclasses != null;
assert users[0].favoriteStructComplex.goodDataclasses.getValue() == null;
}
}

@Test
public void TestBenchmarkBulkUnmarshal() throws Exception {
var userIds = new ArrayList<String>();
Expand Down
Loading