Skip to content

Commit 6a70c96

Browse files
LuQQiuCopilot
andauthored
fix: add child field conversion support in JsonArrowSchemaConverter (#187)
Fixes a critical bug in `JsonArrowSchemaConverter` where child fields for complex Arrow types (list, struct, map) were not being converted, causing "Lists have one child Field. Found: none" errors when creating Lance tables with array columns. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 6907a42 commit 6a70c96

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

java/lance-namespace-core/src/main/java/com/lancedb/lance/namespace/util/JsonArrowSchemaConverter.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ private static Field convertToArrowField(JsonArrowField jsonField) {
6565
jsonField.getMetadata() != null ? jsonField.getMetadata() : new HashMap<>();
6666

6767
FieldType fieldType = new FieldType(nullable, arrowType, null, metadata);
68-
return new Field(name, fieldType, null);
68+
69+
// Convert child fields if they exist (needed for list, struct, map, etc.)
70+
List<Field> children = null;
71+
boolean hasChildFields = jsonField.getType() != null && jsonField.getType().getFields() != null;
72+
if (hasChildFields) {
73+
children = new ArrayList<>();
74+
for (JsonArrowField childField : jsonField.getType().getFields()) {
75+
children.add(convertToArrowField(childField));
76+
}
77+
}
78+
79+
return new Field(name, fieldType, children);
6980
}
7081

7182
private static ArrowType convertToArrowType(JsonArrowDataType jsonType) {

0 commit comments

Comments
 (0)