@@ -88,27 +88,16 @@ def __from_arrow__(
88
88
89
89
array = array .cast (pyarrow_type )
90
90
91
- if isinstance (array , pyarrow .Array ):
92
- chunks = [array ]
93
- else :
94
- # pyarrow.ChunkedArray
95
- chunks = array .chunks
96
-
97
- results = []
98
- for arr in chunks :
99
- data , mask = pyarrow_array_to_numpy_and_mask (arr , dtype = self .numpy_dtype )
100
- num_arr = array_class (data .copy (), ~ mask , copy = False )
101
- results .append (num_arr )
102
-
103
- if not results :
104
- return array_class (
105
- np .array ([], dtype = self .numpy_dtype ), np .array ([], dtype = np .bool_ )
106
- )
107
- elif len (results ) == 1 :
108
- # avoid additional copy in _concat_same_type
109
- return results [0 ]
110
- else :
111
- return array_class ._concat_same_type (results )
91
+ if isinstance (array , pyarrow .ChunkedArray ):
92
+ # TODO this "if" can be removed when requiring pyarrow >= 10.0, which fixed
93
+ # combine_chunks for empty arrays https://github.com/apache/arrow/pull/13757
94
+ if array .num_chunks == 0 :
95
+ array = pyarrow .array ([], type = array .type )
96
+ else :
97
+ array = array .combine_chunks ()
98
+
99
+ data , mask = pyarrow_array_to_numpy_and_mask (array , dtype = self .numpy_dtype )
100
+ return array_class (data .copy (), ~ mask , copy = False )
112
101
113
102
@classmethod
114
103
def _str_to_dtype_mapping (cls ) -> Mapping [str , NumericDtype ]:
0 commit comments