Skip to content

Commit

Permalink
handle empty responses
Browse files Browse the repository at this point in the history
  • Loading branch information
IanRFerguson committed Jun 7, 2024
1 parent 3835de2 commit c5bae0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 100 deletions.
10 changes: 9 additions & 1 deletion klondike/snowflake/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,15 @@ def __query(self, sql: str):
_cursor.execute(sql)
_resp = _cursor.fetch_arrow_batches()

return pl.from_arrow(_resp)
try:
return pl.from_arrow(_resp)
except ValueError as ve:
# NOTE - This appears to be Polars response to empty fetch_arrow_batches()
# This should be interrogated more, but is functional
if "Must pass schema, or at least one RecordBatch" in str(ve):
logger.debug("No results obtained via query")
return pl.DataFrame()
raise

def read_dataframe(self, sql: str) -> pl.DataFrame:
"""
Expand Down
99 changes: 0 additions & 99 deletions tests/test_bigquery_connector.py

This file was deleted.

0 comments on commit c5bae0f

Please sign in to comment.