Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion 15 src/databricks/sql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,22 @@ def fetchall_arrow(self) -> "pyarrow.Table":
while not self.has_been_closed_server_side and self.has_more_rows:
self._fill_results_buffer()
partial_results = self.results.remaining_rows()
results = pyarrow.concat_tables([results, partial_results])
if isinstance(results, ColumnTable) and isinstance(
Comment thread
shivam2680 marked this conversation as resolved.
Comment thread
shivam2680 marked this conversation as resolved.
partial_results, ColumnTable
):
results = self.merge_columnar(results, partial_results)
else:
results = pyarrow.concat_tables([results, partial_results])
self._next_row_index += partial_results.num_rows

# If PyArrow is installed and we have a ColumnTable result, convert it to PyArrow Table
# Valid only for metadata commands result set
if isinstance(results, ColumnTable) and pyarrow:
Comment thread
shivam2680 marked this conversation as resolved.
data = {
name: col
for name, col in zip(results.column_names, results.column_table)
}
return pyarrow.Table.from_pydict(data)
return results

def fetchall_columnar(self):
Expand Down
7 changes: 7 additions & 0 deletions 7 tests/e2e/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,13 @@ def test_decimal_not_returned_as_strings_arrow(self):
decimal_type = arrow_df.field(0).type
assert pyarrow.types.is_decimal(decimal_type)

@skipUnless(pysql_supports_arrow(), "arrow test needs arrow support")
def test_catalogs_returns_arrow_table(self):
with self.cursor() as cursor:
cursor.catalogs()
results = cursor.fetchall_arrow()
assert isinstance(results, pyarrow.Table)

def test_close_connection_closes_cursors(self):

from databricks.sql.thrift_api.TCLIService import ttypes
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.