Skip to content

Commit 5363c39

Browse files
committed
cast listarray to largelistarray during concat
1 parent 79224a5 commit 5363c39

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/datasets/table.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,21 @@ def _concat_blocks(blocks: List[Union[TableBlock, pa.Table]], axis: int = 0) ->
12651265
pa_tables = [table.table if hasattr(table, "table") else table for table in blocks]
12661266
if axis == 0:
12671267
# we set promote=True to fill missing columns with null values
1268-
return pa.concat_tables(pa_tables, promote=True)
1268+
large_list_schema_map = {field.name: field for field in pa_tables[0].schema} # intialize
1269+
large_list_flag = False
1270+
for table in pa_tables:
1271+
for field in table.schema:
1272+
if pa.types.is_large_list(field.type):
1273+
large_list_schema_map[field.name] = field
1274+
large_list_flag = True
1275+
if large_list_flag: # cast ListArray to LargeListArray
1276+
large_list_schema = pa.schema(list(large_list_schema_map.values()))
1277+
new_tables = []
1278+
for table in pa_tables:
1279+
new_tables.append(table.cast(large_list_schema))
1280+
return pa.concat_tables(new_tables, promote=True)
1281+
else:
1282+
return pa.concat_tables(pa_tables, promote=True)
12691283
elif axis == 1:
12701284
for i, table in enumerate(pa_tables):
12711285
if i == 0:

0 commit comments

Comments
 (0)