From 1f96439b3dbd27f11be5e2af84f290ec6094d0a4 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 19 Jan 2024 17:35:26 -0600 Subject: [PATCH] docs: remove unused query code sample (#1769) * docs: remove unused query code sample This sample was moved in https://github.com/googleapis/python-bigquery/pull/1722/files#diff-2e8df14049580f42d6c73a3209838b96f3c9b185d2d7f2688683ae60bb2e7c43. Docs updated in internal change 597332356. * remove sample test too * update reference to query() sample in usage guides --------- Co-authored-by: Kira --- docs/usage/queries.rst | 4 +-- samples/client_query.py | 41 ------------------------------ samples/tests/test_client_query.py | 27 -------------------- 3 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 samples/client_query.py delete mode 100644 samples/tests/test_client_query.py diff --git a/docs/usage/queries.rst b/docs/usage/queries.rst index fc57e54de..56be8497e 100644 --- a/docs/usage/queries.rst +++ b/docs/usage/queries.rst @@ -5,9 +5,9 @@ Querying data ^^^^^^^^^^^^^ Run a query and wait for it to finish with the -:func:`~google.cloud.bigquery.client.Client.query` method: +:func:`~google.cloud.bigquery.client.Client.query_and_wait` method: -.. literalinclude:: ../samples/client_query.py +.. literalinclude:: ../samples/snippets/client_query.py :language: python :dedent: 4 :start-after: [START bigquery_query] diff --git a/samples/client_query.py b/samples/client_query.py deleted file mode 100644 index 80eac854e..000000000 --- a/samples/client_query.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -def client_query() -> None: - # TODO(swast): remove once docs in cloud.google.com have been updated to - # use samples/snippets/client_query.py - - # [START bigquery_query] - - from google.cloud import bigquery - - # Construct a BigQuery client object. - client = bigquery.Client() - - query = """ - SELECT name, SUM(number) as total_people - FROM `bigquery-public-data.usa_names.usa_1910_2013` - WHERE state = 'TX' - GROUP BY name, state - ORDER BY total_people DESC - LIMIT 20 - """ - query_job = client.query(query) # Make an API request. - - print("The query data:") - for row in query_job: - # Row values can be accessed by field name or index. - print("name={}, count={}".format(row[0], row["total_people"])) - # [END bigquery_query] diff --git a/samples/tests/test_client_query.py b/samples/tests/test_client_query.py deleted file mode 100644 index 5d4fb9c94..000000000 --- a/samples/tests/test_client_query.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import typing - -from .. import client_query - -if typing.TYPE_CHECKING: - import pytest - - -def test_client_query(capsys: "pytest.CaptureFixture[str]") -> None: - client_query.client_query() - out, err = capsys.readouterr() - assert "The query data:" in out - assert "name=James, count=272793" in out