@@ -86,7 +86,7 @@ def from_pyarrow(self, table: pa.Table) -> ManagedArrowTable:
86
86
columns : list [pa .ChunkedArray ] = []
87
87
fields : list [schemata .SchemaItem ] = []
88
88
for name , arr in zip (table .column_names , table .columns ):
89
- new_arr , bf_type = _adapt_arrow_array (arr )
89
+ new_arr , bf_type = _adapt_chunked_array (arr )
90
90
columns .append (new_arr )
91
91
fields .append (schemata .SchemaItem (name , bf_type ))
92
92
@@ -279,10 +279,26 @@ def _adapt_pandas_series(
279
279
raise e
280
280
281
281
282
- def _adapt_arrow_array (
283
- array : Union [pa .ChunkedArray , pa .Array ]
284
- ) -> tuple [Union [pa .ChunkedArray , pa .Array ], bigframes .dtypes .Dtype ]:
282
+ def _adapt_chunked_array (
283
+ chunked_array : pa .ChunkedArray ,
284
+ ) -> tuple [pa .ChunkedArray , bigframes .dtypes .Dtype ]:
285
+ if len (chunked_array .chunks ) == 0 :
286
+ return _adapt_arrow_array (chunked_array .combine_chunks ())
287
+ dtype = None
288
+ arrays = []
289
+ for chunk in chunked_array .chunks :
290
+ array , arr_dtype = _adapt_arrow_array (chunk )
291
+ arrays .append (array )
292
+ dtype = dtype or arr_dtype
293
+ assert dtype is not None
294
+ return pa .chunked_array (arrays ), dtype
295
+
296
+
297
+ def _adapt_arrow_array (array : pa .Array ) -> tuple [pa .Array , bigframes .dtypes .Dtype ]:
285
298
"""Normalize the array to managed storage types. Preverse shapes, only transforms values."""
299
+ if array .offset != 0 : # Offset arrays don't have all operations implemented
300
+ return _adapt_arrow_array (pa .concat_arrays ([array ]))
301
+
286
302
if pa .types .is_struct (array .type ):
287
303
assert isinstance (array , pa .StructArray )
288
304
assert isinstance (array .type , pa .StructType )
0 commit comments