@@ -277,6 +277,7 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
277277if size < 0 :
278278raise ValueError ("size argument for fetchmany is %s but must be >= 0" ,size )
279279results = self .results .next_n_rows (size )
280+ partial_result_chunks = [results ]
280281n_remaining_rows = size - results .num_rows
281282self ._next_row_index += results .num_rows
282283
@@ -287,11 +288,11 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
287288 ):
288289self ._fill_results_buffer ()
289290partial_results = self .results .next_n_rows (n_remaining_rows )
290- results = pyarrow . concat_tables ([ results , partial_results ] )
291+ partial_result_chunks . append ( partial_results )
291292n_remaining_rows -= partial_results .num_rows
292293self ._next_row_index += partial_results .num_rows
293294
294- return results
295+ return pyarrow . concat_tables ( partial_result_chunks , use_threads = True )
295296
296297def fetchmany_columnar (self ,size :int ):
297298"""
@@ -322,7 +323,7 @@ def fetchall_arrow(self) -> "pyarrow.Table":
322323"""Fetch all (remaining) rows of a query result, returning them as a PyArrow table."""
323324results = self .results .remaining_rows ()
324325self ._next_row_index += results .num_rows
325-
326+ partial_result_chunks = [ results ]
326327while not self .has_been_closed_server_side and self .has_more_rows :
327328self ._fill_results_buffer ()
328329partial_results = self .results .remaining_rows ()
@@ -331,7 +332,7 @@ def fetchall_arrow(self) -> "pyarrow.Table":
331332 ):
332333results = self .merge_columnar (results ,partial_results )
333334else :
334- results = pyarrow . concat_tables ([ results , partial_results ] )
335+ partial_result_chunks . append ( partial_results )
335336self ._next_row_index += partial_results .num_rows
336337
337338# If PyArrow is installed and we have a ColumnTable result, convert it to PyArrow Table
@@ -342,7 +343,7 @@ def fetchall_arrow(self) -> "pyarrow.Table":
342343for name ,col in zip (results .column_names ,results .column_table )
343344 }
344345return pyarrow .Table .from_pydict (data )
345- return results
346+ return pyarrow . concat_tables ( partial_result_chunks , use_threads = True )
346347
347348def fetchall_columnar (self ):
348349"""Fetch all (remaining) rows of a query result, returning them as a Columnar table."""