From 6e10935d023ecb33de4168798a1ddb38e4f77af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Thu, 20 Aug 2026 15:42:00 -0500 Subject: [PATCH 1/3] chore: user agent to include 'legacy-gcb' for pandas-related API requests This will allow us to disambiguate pandas-gbq usage from usage that hits it indirectly from the google-cloud-bigquery package. --- .../google-cloud-bigquery/google/cloud/bigquery/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py index 07fec2fc0fa9..df4db5650dd8 100644 --- a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py +++ b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py @@ -641,9 +641,9 @@ def _ensure_bqstorage_client( pandas_gbq = None # type: ignore if pandas_gbq is None: - user_agent = "pandas-gbq/0.0.0" + user_agent = "pandas-gbq/0.0.0 legacy-gcb" else: - user_agent = f"pandas-gbq/{pandas_gbq.__version__}" + user_agent = f"pandas-gbq/{pandas_gbq.__version__} legacy-gcb" if client_info is None: amended_client_info = google.api_core.gapic_v1.client_info.ClientInfo( From f30d112d1d51ef7e57544e70eead42adeb15e970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Thu, 20 Aug 2026 15:55:57 -0500 Subject: [PATCH 2/3] update user-agent in unit tests --- packages/google-cloud-bigquery/tests/unit/test_client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/google-cloud-bigquery/tests/unit/test_client.py b/packages/google-cloud-bigquery/tests/unit/test_client.py index d9c7fbbfbe5a..94023f7ee725 100644 --- a/packages/google-cloud-bigquery/tests/unit/test_client.py +++ b/packages/google-cloud-bigquery/tests/unit/test_client.py @@ -865,7 +865,7 @@ def test_ensure_bqstorage_client_pandas_gbq_installed(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args self.assertEqual( - kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.13.0" + kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.13.0 legacy-gcb" ) def test_ensure_bqstorage_client_pandas_gbq_not_installed(self): @@ -888,7 +888,7 @@ def test_ensure_bqstorage_client_pandas_gbq_not_installed(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args - self.assertEqual(kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.0.0") + self.assertEqual(kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.0.0 legacy-gcb") def test_ensure_bqstorage_client_client_info_none(self): bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") @@ -905,7 +905,7 @@ def test_ensure_bqstorage_client_client_info_none(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args - self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0") + self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0 legacy-gcb") def test_ensure_bqstorage_client_client_info_user_agent_none(self): bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") @@ -926,7 +926,7 @@ def test_ensure_bqstorage_client_client_info_user_agent_none(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args - self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0") + self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0 legacy-gcb") def test_ensure_bqstorage_client_missing_dependency(self): creds = _make_credentials() From 290204309ce16998d6e7cb640da0a326c011b15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Thu, 20 Aug 2026 21:17:39 +0000 Subject: [PATCH 3/3] blacken --- .../google-cloud-bigquery/tests/unit/test_client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/google-cloud-bigquery/tests/unit/test_client.py b/packages/google-cloud-bigquery/tests/unit/test_client.py index 94023f7ee725..e7063693ff6f 100644 --- a/packages/google-cloud-bigquery/tests/unit/test_client.py +++ b/packages/google-cloud-bigquery/tests/unit/test_client.py @@ -888,7 +888,9 @@ def test_ensure_bqstorage_client_pandas_gbq_not_installed(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args - self.assertEqual(kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.0.0 legacy-gcb") + self.assertEqual( + kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.0.0 legacy-gcb" + ) def test_ensure_bqstorage_client_client_info_none(self): bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") @@ -905,7 +907,9 @@ def test_ensure_bqstorage_client_client_info_none(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args - self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0 legacy-gcb") + self.assertEqual( + kwargs["client_info"].user_agent, "pandas-gbq/0.0.0 legacy-gcb" + ) def test_ensure_bqstorage_client_client_info_user_agent_none(self): bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") @@ -926,7 +930,9 @@ def test_ensure_bqstorage_client_client_info_user_agent_none(self): mock_client.assert_called_once() _, kwargs = mock_client.call_args - self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0 legacy-gcb") + self.assertEqual( + kwargs["client_info"].user_agent, "pandas-gbq/0.0.0 legacy-gcb" + ) def test_ensure_bqstorage_client_missing_dependency(self): creds = _make_credentials()