File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1415,9 +1415,22 @@ def fetchall_arrow(self) -> "pyarrow.Table":
1415
1415
while not self .has_been_closed_server_side and self .has_more_rows :
1416
1416
self ._fill_results_buffer ()
1417
1417
partial_results = self .results .remaining_rows ()
1418
- results = pyarrow .concat_tables ([results , partial_results ])
1418
+ if isinstance (results , ColumnTable ) and isinstance (
1419
+ partial_results , ColumnTable
1420
+ ):
1421
+ results = self .merge_columnar (results , partial_results )
1422
+ else :
1423
+ results = pyarrow .concat_tables ([results , partial_results ])
1419
1424
self ._next_row_index += partial_results .num_rows
1420
1425
1426
+ # If PyArrow is installed and we have a ColumnTable result,
1427
+ # convert it to a PyArrow Table for consistency with pre-3.5.0 behavior
1428
+ if isinstance (results , ColumnTable ) and pyarrow :
1429
+ data = {
1430
+ name : col
1431
+ for name , col in zip (results .column_names , results .column_table )
1432
+ }
1433
+ return pyarrow .Table .from_pydict (data )
1421
1434
return results
1422
1435
1423
1436
def fetchall_columnar (self ):
Original file line number Diff line number Diff line change @@ -801,6 +801,13 @@ def test_decimal_not_returned_as_strings_arrow(self):
801
801
decimal_type = arrow_df .field (0 ).type
802
802
assert pyarrow .types .is_decimal (decimal_type )
803
803
804
+ @skipUnless (pysql_supports_arrow (), "arrow test needs arrow support" )
805
+ def test_catalogs_returns_arrow_table (self ):
806
+ with self .cursor () as cursor :
807
+ cursor .catalogs ()
808
+ results = cursor .fetchall_arrow ()
809
+ assert isinstance (results , pyarrow .Table )
810
+
804
811
def test_close_connection_closes_cursors (self ):
805
812
806
813
from databricks .sql .thrift_api .TCLIService import ttypes
You can’t perform that action at this time.
0 commit comments