@@ -580,8 +580,8 @@ ERL_NIF_TERM get_arrow_array_list_children(ErlNifEnv *env, struct ArrowSchema *
580580 const uint8_t * bitmap_buffer = (const uint8_t *)values->buffers [bitmap_buffer_index];
581581 struct ArrowSchema * items_schema = schema->children [0 ];
582582 struct ArrowArray * items_values = values->children [0 ];
583- if (strcmp (" item" , items_schema->name ) != 0 ) {
584- return erlang::nif::error (env, " invalid ArrowSchema (list), its single child is not named item" );
583+ if (!( strcmp (" item" , items_schema->name ) == 0 || strcmp ( " l " , items_schema-> name ) == 0 ) ) {
584+ return erlang::nif::error (env, " invalid ArrowSchema (list), its single child is not named ` item` or `l` " );
585585 }
586586
587587 std::vector<ERL_NIF_TERM> children;
@@ -594,6 +594,8 @@ ERL_NIF_TERM get_arrow_array_list_children(ErlNifEnv *env, struct ArrowSchema *
594594 bool items_nullable = (schema->flags & ARROW_FLAG_NULLABLE) || (values->null_count > 0 );
595595
596596 int has_error = 0 ;
597+ // Use "item" as the canonical name for list elements
598+ ERL_NIF_TERM item_name_term = erlang::nif::make_binary (env, " item" );
597599 auto get_list_children_with_offsets = [&](auto offsets) -> void {
598600 for (int64_t i = offset; i < offset + count; i++) {
599601 if (bitmap_buffer && items_nullable) {
@@ -619,7 +621,8 @@ ERL_NIF_TERM get_arrow_array_list_children(ErlNifEnv *env, struct ArrowSchema *
619621 if (enif_is_identical (childrens[1 ], kAtomNil )) {
620622 children.emplace_back (kAtomNil );
621623 } else {
622- children.emplace_back (make_adbc_column (env, schema, values, childrens[0 ], children_type, children_nullable, children_metadata, childrens[1 ]));
624+ // Use "item" instead of childrens[0] (the schema's name)
625+ children.emplace_back (make_adbc_column (env, schema, values, item_name_term, children_type, children_nullable, children_metadata, childrens[1 ]));
623626 }
624627 }
625628 }
@@ -637,6 +640,9 @@ ERL_NIF_TERM get_arrow_array_list_children(ErlNifEnv *env, struct ArrowSchema *
637640 if (count == -1 ) count = values->length ;
638641 if (count > values->length ) count = values->length - offset;
639642 bool items_nullable = (schema->flags & ARROW_FLAG_NULLABLE) || (values->null_count > 0 );
643+
644+ // Use "item" as the canonical name for list elements
645+ ERL_NIF_TERM item_name_term = erlang::nif::make_binary (env, " item" );
640646 for (int64_t child_i = offset; child_i < offset + count; child_i++) {
641647 if (bitmap_buffer && items_nullable) {
642648 uint8_t vbyte = bitmap_buffer[child_i / 8 ];
@@ -659,7 +665,8 @@ ERL_NIF_TERM get_arrow_array_list_children(ErlNifEnv *env, struct ArrowSchema *
659665 if (enif_is_identical (childrens[1 ], kAtomNil )) {
660666 children.emplace_back (kAtomNil );
661667 } else {
662- children.emplace_back (make_adbc_column (env, schema, values, childrens[0 ], children_type, children_nullable, children_metadata, childrens[1 ]));
668+ // Use "item" instead of childrens[0] (the schema's name)
669+ children.emplace_back (make_adbc_column (env, schema, values, item_name_term, children_type, children_nullable, children_metadata, childrens[1 ]));
663670 }
664671 }
665672 }
@@ -704,8 +711,8 @@ ERL_NIF_TERM get_arrow_array_list_view(ErlNifEnv *env, struct ArrowSchema * sche
704711
705712 struct ArrowSchema * items_schema = schema->children [0 ];
706713 struct ArrowArray * items_values = values->children [0 ];
707- if (strcmp (" item" , items_schema->name ) != 0 ) {
708- return erlang::nif::error (env, " invalid ArrowSchema (list), its single child is not named item" );
714+ if (!( strcmp (" item" , items_schema->name ) == 0 || strcmp ( " l " , items_schema-> name ) == 0 ) ) {
715+ return erlang::nif::error (env, " invalid ArrowSchema (list), its single child is not named ` item` or `l` " );
709716 }
710717 if (count == -1 ) count = values->length ;
711718 if (count > values->length ) count = values->length - offset;
@@ -733,7 +740,9 @@ ERL_NIF_TERM get_arrow_array_list_view(ErlNifEnv *env, struct ArrowSchema * sche
733740 values_term = kAtomNil ;
734741 } else {
735742 bool nullable = items_schema->flags & ARROW_FLAG_NULLABLE || items_values->null_count > 0 ;
736- values_term = make_adbc_column (env, schema, values, childrens[0 ], children_type, nullable, children_metadata, childrens[1 ]);
743+ // Use "item" as the canonical name for list elements
744+ ERL_NIF_TERM item_name_term = erlang::nif::make_binary (env, " item" );
745+ values_term = make_adbc_column (env, schema, values, item_name_term, children_type, nullable, children_metadata, childrens[1 ]);
737746 }
738747 }
739748
0 commit comments