Skip to content

Commit

Permalink
BigQuery: deprecate list_dataset_tables in favor of list_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
tswast committed Dec 22, 2017
1 parent 29620a1 commit 4aff75d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import functools
import os
import uuid
import warnings

import six

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions bigquery/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 4aff75d

Please sign in to comment.