From 4aff75d620e1784d7926dc05076394e26f725ab6 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Thu, 21 Dec 2017 17:28:30 -0800 Subject: [PATCH] BigQuery: deprecate list_dataset_tables in favor of list_tables --- bigquery/google/cloud/bigquery/client.py | 15 +++++++++++++-- bigquery/tests/system.py | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bigquery/google/cloud/bigquery/client.py b/bigquery/google/cloud/bigquery/client.py index d851d91f5e460..84f38a26ae494 100644 --- a/bigquery/google/cloud/bigquery/client.py +++ b/bigquery/google/cloud/bigquery/client.py @@ -20,6 +20,7 @@ import functools import os import uuid +import warnings import six @@ -389,8 +390,8 @@ def update_table(self, table, fields, retry=DEFAULT_RETRY): method='PATCH', path=table.path, data=partial, headers=headers) return Table.from_api_repr(api_response) - def list_dataset_tables(self, dataset, max_results=None, page_token=None, - retry=DEFAULT_RETRY): + def list_tables(self, dataset, max_results=None, page_token=None, + retry=DEFAULT_RETRY): """List tables in the dataset. See @@ -432,6 +433,16 @@ def list_dataset_tables(self, dataset, max_results=None, page_token=None, result.dataset = dataset return result + def list_dataset_tables(self, *args, **kwargs): + """DEPRECATED: List tables in the dataset. + + Use :func:`~google.cloud.bigquery.client.Client.list_tables` instead. + """ + warnings.warn( + 'list_dataset_tables is deprecated, use list_tables instead.', + DeprecationWarning) + return self.list_tables(*args, **kwargs) + def delete_dataset(self, dataset, retry=DEFAULT_RETRY): """Delete a dataset. diff --git a/bigquery/tests/system.py b/bigquery/tests/system.py index f6c27e3a8b508..b49b39c80b488 100644 --- a/bigquery/tests/system.py +++ b/bigquery/tests/system.py @@ -230,11 +230,11 @@ def test_get_table_w_public_dataset(self): self.assertEqual( schema_names, ['word', 'word_count', 'corpus', 'corpus_date']) - def test_list_dataset_tables(self): + def test_list_tables(self): DATASET_ID = _make_dataset_id('list_tables') dataset = self.temp_dataset(DATASET_ID) # Retrieve tables before any are created for the dataset. - iterator = Config.CLIENT.list_dataset_tables(dataset) + iterator = Config.CLIENT.list_tables(dataset) all_tables = list(iterator) self.assertEqual(all_tables, []) self.assertIsNone(iterator.next_page_token) @@ -251,7 +251,7 @@ def test_list_dataset_tables(self): self.to_delete.insert(0, created_table) # Retrieve the tables. - iterator = Config.CLIENT.list_dataset_tables(dataset) + iterator = Config.CLIENT.list_tables(dataset) all_tables = list(iterator) self.assertIsNone(iterator.next_page_token) created = [table for table in all_tables