Skip to content

Commit 7c7b121

Browse files
committed
more
1 parent 270e27c commit 7c7b121

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/databricks/sql/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,4 +1230,4 @@ def setinputsizes(self, sizes):
12301230

12311231
def setoutputsize(self, size, column=None):
12321232
"""Does nothing by default"""
1233-
pass
1233+
pass

src/databricks/sql/result_set.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
277277
if size < 0:
278278
raise ValueError("size argument for fetchmany is %s but must be >= 0", size)
279279
results = self.results.next_n_rows(size)
280+
partial_result_chunks = [results]
280281
n_remaining_rows = size - results.num_rows
281282
self._next_row_index += results.num_rows
282283

@@ -287,11 +288,11 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
287288
):
288289
self._fill_results_buffer()
289290
partial_results = self.results.next_n_rows(n_remaining_rows)
290-
results = pyarrow.concat_tables([results, partial_results])
291+
partial_result_chunks.append(partial_results)
291292
n_remaining_rows -= partial_results.num_rows
292293
self._next_row_index += partial_results.num_rows
293294

294-
return results
295+
return pyarrow.concat_tables(partial_result_chunks, use_threads=True)
295296

296297
def 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."""
323324
results = self.results.remaining_rows()
324325
self._next_row_index += results.num_rows
325-
326+
partial_result_chunks = [results]
326327
while not self.has_been_closed_server_side and self.has_more_rows:
327328
self._fill_results_buffer()
328329
partial_results = self.results.remaining_rows()
@@ -331,7 +332,7 @@ def fetchall_arrow(self) -> "pyarrow.Table":
331332
):
332333
results = self.merge_columnar(results, partial_results)
333334
else:
334-
results = pyarrow.concat_tables([results, partial_results])
335+
partial_result_chunks.append(partial_results)
335336
self._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":
342343
for name, col in zip(results.column_names, results.column_table)
343344
}
344345
return pyarrow.Table.from_pydict(data)
345-
return results
346+
return pyarrow.concat_tables(partial_result_chunks, use_threads=True)
346347

347348
def fetchall_columnar(self):
348349
"""Fetch all (remaining) rows of a query result, returning them as a Columnar table."""

0 commit comments

Comments
 (0)