Repository navigation
chore(bigquery): drop bqstorage 2.43.0 workarounds #18805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -775,8 +775,6 @@ def _query_arrow(client, row_count): | |||||||||
|
|
||||||||||
|
|
||||||||||
| def test_query_and_wait_arrow_queries_share_one_bqstorage_client(): | ||||||||||
| from google.cloud.bigquery import client as client_module | ||||||||||
|
|
||||||||||
| with bigquery.Client() as client: | ||||||||||
| # Wrap the client factory to count how many clients get created. | ||||||||||
| ensure = mock.Mock(wraps=client._ensure_bqstorage_client) | ||||||||||
|
|
@@ -794,7 +792,7 @@ def test_query_and_wait_arrow_queries_share_one_bqstorage_client(): | |||||||||
|
|
||||||||||
| for table in tables: | ||||||||||
| assert table.column("x").to_pylist() == list(range(1, 1001)) | ||||||||||
| ensure.assert_called_once_with(transport=client_module._create_bqstorage_transport) | ||||||||||
| ensure.assert_called_once_with() | ||||||||||
| assert shared is not None | ||||||||||
| # Leaving the with block calls close(), which closes the shared channel. | ||||||||||
| assert client._shared_bqstorage_client is None | ||||||||||
|
|
@@ -807,25 +805,19 @@ def test_query_and_wait_arrow_ending_a_read_early_cancels_only_its_stream(): | |||||||||
|
|
||||||||||
| # Wrap ReadRowsStream.cancel() to record calls without changing it. | ||||||||||
| cancel_stream = reader.ReadRowsStream.cancel | ||||||||||
| cancelled_open = [] | ||||||||||
|
|
||||||||||
| def record_open_cancel(stream): | ||||||||||
| # google-cloud-bigquery-storage 2.43.0's __del__ also calls cancel() | ||||||||||
| # on finished streams, which does nothing. Count only cancels of a | ||||||||||
| # stream that's still open. | ||||||||||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/18785): | ||||||||||
| # Count every cancel() once the bqstorage extra requires a release | ||||||||||
| # whose __del__ skips finished streams. | ||||||||||
| if stream._wrapped is not None: | ||||||||||
| cancelled_open.append(stream) | ||||||||||
| cancelled = [] | ||||||||||
|
|
||||||||||
| def record_cancel(stream): | ||||||||||
| cancelled.append(stream._name) | ||||||||||
| return cancel_stream(stream) | ||||||||||
|
|
||||||||||
| with bigquery.Client() as client, mock.patch.object( | ||||||||||
| reader.ReadRowsStream, "cancel", autospec=True, side_effect=record_open_cancel | ||||||||||
| reader.ReadRowsStream, "cancel", autospec=True, side_effect=record_cancel | ||||||||||
| ): | ||||||||||
| ended_early_rows = _query_arrow(client, 100000) | ||||||||||
| ended_early = ended_early_rows.to_arrow_iterable() | ||||||||||
| read_fully = _query_arrow(client, 100000).to_arrow_iterable() | ||||||||||
| read_fully_rows = _query_arrow(client, 100000) | ||||||||||
| read_fully = read_fully_rows.to_arrow_iterable() | ||||||||||
| # Two reads reach the stream, whether or not jobs.query returned a | ||||||||||
| # first page. | ||||||||||
| next(ended_early) | ||||||||||
|
|
@@ -835,8 +827,12 @@ def record_open_cancel(stream): | |||||||||
| ended_early.close() | ||||||||||
| rows.extend(read_fully) | ||||||||||
|
|
||||||||||
| (stream,) = cancelled_open | ||||||||||
| assert stream._name.endswith(f"/jobs/{ended_early_rows.job_id}/streams/_default") | ||||||||||
| # Streams left over from other tests can be garbage collected, and | ||||||||||
| # cancelled, while this one runs, so only look at this test's two streams. | ||||||||||
| ended_early_stream = f"/jobs/{ended_early_rows.job_id}/streams/_default" | ||||||||||
| read_fully_stream = f"/jobs/{read_fully_rows.job_id}/streams/_default" | ||||||||||
| assert sum(name.endswith(ended_early_stream) for name in cancelled) == 1 | ||||||||||
| assert not any(name.endswith(read_fully_stream) for name in cancelled) | ||||||||||
|
Comment on lines
+834
to
+835
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReadRowsStream.init always sets _name before _cancelled and _finished, and del skips cancel() if either flag is unset, so uninitialized streams never reach record_cancel. cancel() also leaves _name intact, and system tests only pass string stream names to read_rows(), so keeping the assertion direct is fine here. |
||||||||||
| table = pyarrow.Table.from_batches(rows) | ||||||||||
| assert table.column("x").to_pylist() == list(range(1, 100001)) | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on bumping this now? With the current corporate environment, folks are much more willing to push customers onto newer (presumably more secure) versions of our client libraries and other dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should bump it. But we need a release out for both bigquery-storage and bigquery (to unblock bigquery-storage release) which we won't do until the end of release freeze. So I'll change this back to draft.