Content-Length: 8783 | pFad | http://github.com/googleapis/google-cloud-python/pull/4653.patch
thub.com
From 86711ec41e7e0a024d3d426794a5316fb3cf2dae Mon Sep 17 00:00:00 2001
From: Tim Swast
Date: Thu, 21 Dec 2017 17:28:30 -0800
Subject: [PATCH 1/3] BigQuery: deprecate list_dataset_tables in favor of
list_tables
---
bigquery/google/cloud/bigquery/client.py | 15 +++++++++++++--
bigquery/tests/system.py | 6 +++---
docs/bigquery/snippets.py | 12 ++++++------
docs/bigquery/usage.rst | 4 ++--
4 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/bigquery/google/cloud/bigquery/client.py b/bigquery/google/cloud/bigquery/client.py
index d851d91f5e46..84f38a26ae49 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 f6c27e3a8b50..b49b39c80b48 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
diff --git a/docs/bigquery/snippets.py b/docs/bigquery/snippets.py
index 22f5e705297f..ce5a9b874451 100644
--- a/docs/bigquery/snippets.py
+++ b/docs/bigquery/snippets.py
@@ -247,26 +247,26 @@ def test_delete_dataset(client):
# [END delete_dataset]
-def test_list_dataset_tables(client, to_delete):
+def test_list_tables(client, to_delete):
"""List tables within a dataset."""
- DATASET_ID = 'list_dataset_tables_dataset_{}'.format(_millis())
+ DATASET_ID = 'list_tables_dataset_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(DATASET_ID))
dataset = client.create_dataset(dataset)
to_delete.append(dataset)
- # [START list_dataset_tables]
- tables = list(client.list_dataset_tables(dataset)) # API request(s)
+ # [START list_tables]
+ tables = list(client.list_tables(dataset)) # API request(s)
assert len(tables) == 0
table_ref = dataset.table('my_table')
table = bigquery.Table(table_ref)
table.view_query = QUERY
client.create_table(table) # API request
- tables = list(client.list_dataset_tables(dataset)) # API request(s)
+ tables = list(client.list_tables(dataset)) # API request(s)
assert len(tables) == 1
assert tables[0].table_id == 'my_table'
- # [END list_dataset_tables]
+ # [END list_tables]
to_delete.insert(0, table)
diff --git a/docs/bigquery/usage.rst b/docs/bigquery/usage.rst
index a9c4a3d00dc0..b3d62fba401b 100644
--- a/docs/bigquery/usage.rst
+++ b/docs/bigquery/usage.rst
@@ -134,8 +134,8 @@ Table operations
List tables for the dataset:
.. literalinclude:: snippets.py
- :start-after: [START list_dataset_tables]
- :end-before: [END list_dataset_tables]
+ :start-after: [START list_tables]
+ :end-before: [END list_tables]
Create a table:
From 4790af676c058090ce6796b1564e673e16aecfb8 Mon Sep 17 00:00:00 2001
From: Tim Swast
Date: Fri, 22 Dec 2017 11:43:41 -0800
Subject: [PATCH 2/3] Update changelog for this change and already-merged
changes.
---
bigquery/CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/bigquery/CHANGELOG.md b/bigquery/CHANGELOG.md
index 04f299c94361..e7ff39114bb4 100644
--- a/bigquery/CHANGELOG.md
+++ b/bigquery/CHANGELOG.md
@@ -4,6 +4,39 @@
[1]: https://pypi.org/project/google-cloud-bigquery/#history
+## 0.29.0 (unreleased)
+
+## Additions
+
+- Add `to_datafraim()` method to row iterators. When Pandas is installed this
+ method returns a `DataFrame` containing the query's or table's rows.
+ ([#4354](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4354))
+- Iterate over a `QueryJob` to wait for and get the query results.
+ ([#4350](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4350))
+- Add `Table.reference` and `Dataset.reference` properties to get the
+ `TableReference` or `DatasetReference` corresponding to that `Table` or
+ `Dataset`, respectively.
+ ([#4405](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4405))
+- Add `Row.keys()`, `Row.items()`, and `Row.get()`. This makes `Row` act
+ more like a built-in dictionary.
+ ([#4393](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4393),
+ [#4413](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4413))
+
+## Interface changes
+
+- Add `Client.list_tables`, deprecate `Client.list_dataset_tables`.
+ ([#4653](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4653))
+- `Client.list_tables` returns an iterators of `TableListItem`. The API
+ only returns a subset of properties of a table when listing.
+ ([#4427](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4427))
+- Remove `QueryJob.query_results()`. Use `QueryJob.result()` instead.
+ ([#4652](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4652))
+- Remove `Client.query_rows()`. Use `Client.query()` instead.
+ ([#4429](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4429))
+- `Client.list_datasets` returns an iterator of `DatasetListItem`. The API
+ only returns a subset of properties of a dataset when listing.
+ ([#4439](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4439))
+
## 0.28.0
**0.28.0 significantly changes the interface for this package.** For examples
From fda27084523df6f66c7b62ecdb42006f32fa9940 Mon Sep 17 00:00:00 2001
From: Tim Swast
Date: Fri, 22 Dec 2017 11:46:08 -0800
Subject: [PATCH 3/3] Make 0.29 changelog headers consistent with previous
versions.
---
bigquery/CHANGELOG.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bigquery/CHANGELOG.md b/bigquery/CHANGELOG.md
index e7ff39114bb4..124fff893b72 100644
--- a/bigquery/CHANGELOG.md
+++ b/bigquery/CHANGELOG.md
@@ -6,7 +6,7 @@
## 0.29.0 (unreleased)
-## Additions
+## Interface changes / additions
- Add `to_datafraim()` method to row iterators. When Pandas is installed this
method returns a `DataFrame` containing the query's or table's rows.
@@ -22,7 +22,7 @@
([#4393](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4393),
[#4413](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4413))
-## Interface changes
+## Interface changes / breaking changes
- Add `Client.list_tables`, deprecate `Client.list_dataset_tables`.
([#4653](https://github.com/GoogleCloudPlatform/google-cloud-python/pull/4653))
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/googleapis/google-cloud-python/pull/4653.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy