File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1433,9 +1433,22 @@ def fetchall_arrow(self) -> "pyarrow.Table":
14331433 while not self .has_been_closed_server_side and self .has_more_rows :
14341434 self ._fill_results_buffer ()
14351435 partial_results = self .results .remaining_rows ()
1436- results = pyarrow .concat_tables ([results , partial_results ])
1436+ if isinstance (results , ColumnTable ) and isinstance (
1437+ partial_results , ColumnTable
1438+ ):
1439+ results = self .merge_columnar (results , partial_results )
1440+ else :
1441+ results = pyarrow .concat_tables ([results , partial_results ])
14371442 self ._next_row_index += partial_results .num_rows
14381443
1444+ # If PyArrow is installed and we have a ColumnTable result, convert it to PyArrow Table
1445+ # Valid only for metadata commands result set
1446+ if isinstance (results , ColumnTable ) and pyarrow :
1447+ data = {
1448+ name : col
1449+ for name , col in zip (results .column_names , results .column_table )
1450+ }
1451+ return pyarrow .Table .from_pydict (data )
14391452 return results
14401453
14411454 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):
801801 decimal_type = arrow_df .field (0 ).type
802802 assert pyarrow .types .is_decimal (decimal_type )
803803
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+
804811 def test_close_connection_closes_cursors (self ):
805812
806813 from databricks .sql .thrift_api .TCLIService import ttypes
You can’t perform that action at this time.
0 commit comments