Skip to content

Commit 017714c

Browse files
authored
BigQuery: deprecate list_dataset_tables in favor of list_tables (#4653)
* BigQuery: deprecate list_dataset_tables in favor of list_tables * Update changelog for this change and already-merged changes. * Make 0.29 changelog headers consistent with previous versions.
1 parent 29620a1 commit 017714c

File tree

5 files changed

+57
-13
lines changed

5 files changed

+57
-13
lines changed

bigquery/CHANGELOG.md

+33
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,39 @@
44

55
[1]: https://pypi.org/project/google-cloud-bigquery/#history
66

7+
## 0.29.0 (unreleased)
8+
9+
## Interface changes / additions
10+
11+
- Add `to_dataframe()` method to row iterators. When Pandas is installed this
12+
method returns a `DataFrame` containing the query's or table's rows.
13+
([#4354](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4354))
14+
- Iterate over a `QueryJob` to wait for and get the query results.
15+
([#4350](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4350))
16+
- Add `Table.reference` and `Dataset.reference` properties to get the
17+
`TableReference` or `DatasetReference` corresponding to that `Table` or
18+
`Dataset`, respectively.
19+
([#4405](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4405))
20+
- Add `Row.keys()`, `Row.items()`, and `Row.get()`. This makes `Row` act
21+
more like a built-in dictionary.
22+
([#4393](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4393),
23+
[#4413](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4413))
24+
25+
## Interface changes / breaking changes
26+
27+
- Add `Client.list_tables`, deprecate `Client.list_dataset_tables`.
28+
([#4653](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4653))
29+
- `Client.list_tables` returns an iterators of `TableListItem`. The API
30+
only returns a subset of properties of a table when listing.
31+
([#4427](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4427))
32+
- Remove `QueryJob.query_results()`. Use `QueryJob.result()` instead.
33+
([#4652](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4652))
34+
- Remove `Client.query_rows()`. Use `Client.query()` instead.
35+
([#4429](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4429))
36+
- `Client.list_datasets` returns an iterator of `DatasetListItem`. The API
37+
only returns a subset of properties of a dataset when listing.
38+
([#4439](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4439))
39+
740
## 0.28.0
841

942
**0.28.0 significantly changes the interface for this package.** For examples

bigquery/google/cloud/bigquery/client.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import functools
2121
import os
2222
import uuid
23+
import warnings
2324

2425
import six
2526

@@ -389,8 +390,8 @@ def update_table(self, table, fields, retry=DEFAULT_RETRY):
389390
method='PATCH', path=table.path, data=partial, headers=headers)
390391
return Table.from_api_repr(api_response)
391392

392-
def list_dataset_tables(self, dataset, max_results=None, page_token=None,
393-
retry=DEFAULT_RETRY):
393+
def list_tables(self, dataset, max_results=None, page_token=None,
394+
retry=DEFAULT_RETRY):
394395
"""List tables in the dataset.
395396
396397
See
@@ -432,6 +433,16 @@ def list_dataset_tables(self, dataset, max_results=None, page_token=None,
432433
result.dataset = dataset
433434
return result
434435

436+
def list_dataset_tables(self, *args, **kwargs):
437+
"""DEPRECATED: List tables in the dataset.
438+
439+
Use :func:`~google.cloud.bigquery.client.Client.list_tables` instead.
440+
"""
441+
warnings.warn(
442+
'list_dataset_tables is deprecated, use list_tables instead.',
443+
DeprecationWarning)
444+
return self.list_tables(*args, **kwargs)
445+
435446
def delete_dataset(self, dataset, retry=DEFAULT_RETRY):
436447
"""Delete a dataset.
437448

bigquery/tests/system.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ def test_get_table_w_public_dataset(self):
230230
self.assertEqual(
231231
schema_names, ['word', 'word_count', 'corpus', 'corpus_date'])
232232

233-
def test_list_dataset_tables(self):
233+
def test_list_tables(self):
234234
DATASET_ID = _make_dataset_id('list_tables')
235235
dataset = self.temp_dataset(DATASET_ID)
236236
# Retrieve tables before any are created for the dataset.
237-
iterator = Config.CLIENT.list_dataset_tables(dataset)
237+
iterator = Config.CLIENT.list_tables(dataset)
238238
all_tables = list(iterator)
239239
self.assertEqual(all_tables, [])
240240
self.assertIsNone(iterator.next_page_token)
@@ -251,7 +251,7 @@ def test_list_dataset_tables(self):
251251
self.to_delete.insert(0, created_table)
252252

253253
# Retrieve the tables.
254-
iterator = Config.CLIENT.list_dataset_tables(dataset)
254+
iterator = Config.CLIENT.list_tables(dataset)
255255
all_tables = list(iterator)
256256
self.assertIsNone(iterator.next_page_token)
257257
created = [table for table in all_tables

docs/bigquery/snippets.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,26 @@ def test_delete_dataset(client):
247247
# [END delete_dataset]
248248

249249

250-
def test_list_dataset_tables(client, to_delete):
250+
def test_list_tables(client, to_delete):
251251
"""List tables within a dataset."""
252-
DATASET_ID = 'list_dataset_tables_dataset_{}'.format(_millis())
252+
DATASET_ID = 'list_tables_dataset_{}'.format(_millis())
253253
dataset = bigquery.Dataset(client.dataset(DATASET_ID))
254254
dataset = client.create_dataset(dataset)
255255
to_delete.append(dataset)
256256

257-
# [START list_dataset_tables]
258-
tables = list(client.list_dataset_tables(dataset)) # API request(s)
257+
# [START list_tables]
258+
tables = list(client.list_tables(dataset)) # API request(s)
259259
assert len(tables) == 0
260260

261261
table_ref = dataset.table('my_table')
262262
table = bigquery.Table(table_ref)
263263
table.view_query = QUERY
264264
client.create_table(table) # API request
265-
tables = list(client.list_dataset_tables(dataset)) # API request(s)
265+
tables = list(client.list_tables(dataset)) # API request(s)
266266

267267
assert len(tables) == 1
268268
assert tables[0].table_id == 'my_table'
269-
# [END list_dataset_tables]
269+
# [END list_tables]
270270

271271
to_delete.insert(0, table)
272272

docs/bigquery/usage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ Table operations
134134
List tables for the dataset:
135135

136136
.. literalinclude:: snippets.py
137-
:start-after: [START list_dataset_tables]
138-
:end-before: [END list_dataset_tables]
137+
:start-after: [START list_tables]
138+
:end-before: [END list_tables]
139139

140140
Create a table:
141141

0 commit comments

Comments
 (0)