From d73cf495b8dfa032a43dc1d58599d0691aaa0efb Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 21 Jun 2023 10:56:12 -0400 Subject: [PATCH 1/3] fix: updates tests based on revised hacker_news tables (#1591) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes four broken tests that failed due to an unexpected change in the Google Public Dataset: Hacker News. The `comments` table was deleted and only the `full` table remained. This edit updates the name of the table in four tests and updates the names of columns in the table as well as updates the expected results for one of the tests. Fixes #1590 🦕 --- tests/system/test_client.py | 29 +++++++++++++++-------------- tests/system/test_pandas.py | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/system/test_client.py b/tests/system/test_client.py index 1437328a8..f4757e30f 100644 --- a/tests/system/test_client.py +++ b/tests/system/test_client.py @@ -1706,8 +1706,8 @@ def test_dbapi_fetch_w_bqstorage_client_large_result_set(self): cursor.execute( """ - SELECT id, `by`, time_ts - FROM `bigquery-public-data.hacker_news.comments` + SELECT id, `by`, timestamp + FROM `bigquery-public-data.hacker_news.full` ORDER BY `id` ASC LIMIT 100000 """ @@ -1717,27 +1717,28 @@ def test_dbapi_fetch_w_bqstorage_client_large_result_set(self): field_name = operator.itemgetter(0) fetched_data = [sorted(row.items(), key=field_name) for row in result_rows] - # Since DB API is not thread safe, only a single result stream should be # requested by the BQ storage client, meaning that results should arrive # in the sorted order. + expected_data = [ [ - ("by", "sama"), - ("id", 15), - ("time_ts", datetime.datetime(2006, 10, 9, 19, 51, 1, tzinfo=UTC)), + ("by", "pg"), + ("id", 1), + ("timestamp", datetime.datetime(2006, 10, 9, 18, 21, 51, tzinfo=UTC)), ], [ - ("by", "pg"), - ("id", 17), - ("time_ts", datetime.datetime(2006, 10, 9, 19, 52, 45, tzinfo=UTC)), + ("by", "phyllis"), + ("id", 2), + ("timestamp", datetime.datetime(2006, 10, 9, 18, 30, 28, tzinfo=UTC)), ], [ - ("by", "pg"), - ("id", 22), - ("time_ts", datetime.datetime(2006, 10, 10, 2, 18, 22, tzinfo=UTC)), + ("by", "phyllis"), + ("id", 3), + ("timestamp", datetime.datetime(2006, 10, 9, 18, 40, 33, tzinfo=UTC)), ], ] + self.assertEqual(fetched_data, expected_data) def test_dbapi_dry_run_query(self): @@ -1769,8 +1770,8 @@ def test_dbapi_connection_does_not_leak_sockets(self): cursor.execute( """ - SELECT id, `by`, time_ts - FROM `bigquery-public-data.hacker_news.comments` + SELECT id, `by`, timestamp + FROM `bigquery-public-data.hacker_news.full` ORDER BY `id` ASC LIMIT 100000 """ diff --git a/tests/system/test_pandas.py b/tests/system/test_pandas.py index ea8cc6d63..726b68f7c 100644 --- a/tests/system/test_pandas.py +++ b/tests/system/test_pandas.py @@ -740,8 +740,8 @@ def test_load_table_from_dataframe_w_explicit_schema_source_format_csv_floats( def test_query_results_to_dataframe(bigquery_client): QUERY = """ - SELECT id, author, time_ts, dead - FROM `bigquery-public-data.hacker_news.comments` + SELECT id, `by`, timestamp, dead + FROM `bigquery-public-data.hacker_news.full` LIMIT 10 """ @@ -749,12 +749,12 @@ def test_query_results_to_dataframe(bigquery_client): assert isinstance(df, pandas.DataFrame) assert len(df) == 10 # verify the number of rows - column_names = ["id", "author", "time_ts", "dead"] + column_names = ["id", "by", "timestamp", "dead"] assert list(df) == column_names # verify the column names exp_datatypes = { "id": int, - "author": str, - "time_ts": pandas.Timestamp, + "by": str, + "timestamp": pandas.Timestamp, "dead": bool, } for _, row in df.iterrows(): @@ -766,8 +766,8 @@ def test_query_results_to_dataframe(bigquery_client): def test_query_results_to_dataframe_w_bqstorage(bigquery_client): query = """ - SELECT id, author, time_ts, dead - FROM `bigquery-public-data.hacker_news.comments` + SELECT id, `by`, timestamp, dead + FROM `bigquery-public-data.hacker_news.full` LIMIT 10 """ @@ -779,12 +779,12 @@ def test_query_results_to_dataframe_w_bqstorage(bigquery_client): assert isinstance(df, pandas.DataFrame) assert len(df) == 10 # verify the number of rows - column_names = ["id", "author", "time_ts", "dead"] + column_names = ["id", "by", "timestamp", "dead"] assert list(df) == column_names exp_datatypes = { "id": int, - "author": str, - "time_ts": pandas.Timestamp, + "by": str, + "timestamp": pandas.Timestamp, "dead": bool, } for index, row in df.iterrows(): From 7d5ba5e0fa9376b4e6baa9b49cef7ed383240ab6 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 21 Jun 2023 14:40:13 -0400 Subject: [PATCH 2/3] test: adjusts test input body based on changes to google-api_core (#1588) Adjusts the body of a specific test to adapt to some changes that come through from google-api-core. --- tests/unit/job/test_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/job/test_base.py b/tests/unit/job/test_base.py index a9760aa9b..a662e92d4 100644 --- a/tests/unit/job/test_base.py +++ b/tests/unit/job/test_base.py @@ -18,6 +18,7 @@ from google.api_core import exceptions import google.api_core.retry +from google.api_core.future import polling import mock import pytest @@ -970,7 +971,7 @@ def test_result_default_wo_state(self): client = _make_client(project=self.PROJECT, connection=conn) job = self._make_one(self.JOB_ID, client) - self.assertIs(job.result(), job) + self.assertIs(job.result(retry=polling.DEFAULT_RETRY), job) begin_call = mock.call( method="POST", From a5d86a3c3e460ed684a9214bc59deebc9ae360c6 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 08:19:35 -0400 Subject: [PATCH 3/3] chore(main): release 3.11.2 (#1592) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Chalmer Lowe --- CHANGELOG.md | 7 +++++++ google/cloud/bigquery/version.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9003d2bfc..5cf542670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ [1]: https://pypi.org/project/google-cloud-bigquery/#history +## [3.11.2](https://github.com/googleapis/python-bigquery/compare/v3.11.1...v3.11.2) (2023-06-21) + + +### Bug Fixes + +* Updates tests based on revised hacker_news tables ([#1591](https://github.com/googleapis/python-bigquery/issues/1591)) ([d73cf49](https://github.com/googleapis/python-bigquery/commit/d73cf495b8dfa032a43dc1d58599d0691aaa0efb)) + ## [3.11.1](https://github.com/googleapis/python-bigquery/compare/v3.11.0...v3.11.1) (2023-06-09) diff --git a/google/cloud/bigquery/version.py b/google/cloud/bigquery/version.py index 90c53a0dd..ced5a95a7 100644 --- a/google/cloud/bigquery/version.py +++ b/google/cloud/bigquery/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "3.11.1" +__version__ = "3.11.2"