fix: add timeout parameter to to_dataframe and to_arrow met… (#2354) · googleapis/python-bigquery@4f67ba2 · GitHub
Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 4f67ba2

Browse files
authored
fix: add timeout parameter to to_dataframe and to_arrow met… (#2354)
### Description This PR adds a `timeout` parameter to the `to_dataframe()` and `to_arrow()` methods (and their corresponding `*_iterable`, `*_geodataframe` and `QueryJob` wrappers) in the BigQuery client library. This addresses an issue where these methods could hang indefinitely if the underlying BigQuery Storage API stream blocked (e.g., due to firewall issues or network interruptions) during the download phase. The added `timeout` parameter ensures that the download operation respects the specified time limit and raises a `concurrent.futures.TimeoutError` if it exceeds the duration. ### Changes - Modified `google/cloud/bigquery/_pandas_helpers.py`: - Updated `_download_table_bqstorage` to accept a `timeout` argument. - Implemented a timeout check within the result processing loop. - Updated wrapper functions `download_dataframe_bqstorage` and `download_arrow_bqstorage` to accept and pass the `timeout` parameter. - Modified `google/cloud/bigquery/table.py`: - Updated `RowIterator` methods (`to_arrow_iterable`, `to_arrow`, `to_dataframe_iterable`, `to_dataframe`, `to_geodataframe`) to accept and pass `timeout`. - Updated `_EmptyRowIterator` methods to match the `RowIterator` signature, preventing `TypeError` when a timeout is provided for empty result sets. - Modified `google/cloud/bigquery/job/query.py`: - Updated `QueryJob` methods (`to_arrow`, `to_dataframe`, `to_geodataframe`) to accept `timeout` and pass it to the result iterator. - Updated unit tests in `tests/unit/job/test_query_pandas.py`, `tests/unit/test_table.py`, and `tests/unit/test_table_pandas.py` to reflect the signature changes. Fixes internal bug: b/468091307
1 parent 40b4cbf commit 4f67ba2

7 files changed

Lines changed: 257 additions & 55 deletions

File tree

google/cloud/bigquery/_pandas_helpers.py

Lines changed: 75 additions & 51 deletions

google/cloud/bigquery/job/query.py

Lines changed: 17 additions & 0 deletions

0 commit comments

Comments
 (0)