[pull] main from googleapis:main#42
Merged
Merged
Conversation
### 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )