Skip to content

Commit 21c0802

Browse files
dpebotJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
* Auto-update dependencies. * Fix natural language samples * Fix pubsub iam samples * Fix language samples * Fix bigquery samples
1 parent 1f0ce24 commit 21c0802

File tree

8 files changed

+20
-67
lines changed

8 files changed

+20
-67
lines changed

samples/snippets/async_query.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,9 @@ def async_query(query):
4848

4949
wait_for_job(query_job)
5050

51-
# Drain the query results by requesting a page at a time.
52-
query_results = query_job.results()
53-
page_token = None
54-
55-
while True:
56-
rows, total_rows, page_token = query_results.fetch_data(
57-
max_results=10,
58-
page_token=page_token)
59-
60-
for row in rows:
61-
print(row)
62-
63-
if not page_token:
64-
break
51+
rows = query_job.results().fetch_data(max_results=10)
52+
for row in rows:
53+
print(row)
6554

6655

6756
if __name__ == '__main__':

samples/snippets/query_params.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,10 @@ def wait_for_job(job):
4343

4444

4545
def print_results(query_results):
46-
"""Print the query results by requesting a page at a time."""
47-
page_token = None
48-
49-
while True:
50-
rows, total_rows, page_token = query_results.fetch_data(
51-
max_results=10,
52-
page_token=page_token)
53-
54-
for row in rows:
55-
print(row)
56-
57-
if not page_token:
58-
break
46+
"""Print the rows in the query's results."""
47+
rows = query_results.fetch_data(max_results=10)
48+
for row in rows:
49+
print(row)
5950

6051

6152
def query_positional_params(corpus, min_word_count):

samples/snippets/query_params_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def test_query_named_params(capsys):
2828
corpus='romeoandjuliet',
2929
min_word_count=100)
3030
out, _ = capsys.readouterr()
31-
assert 'love' in out
31+
assert 'the' in out
3232

3333

3434
def test_query_positional_params(capsys):
3535
query_params.query_positional_params(
3636
corpus='romeoandjuliet',
3737
min_word_count=100)
3838
out, _ = capsys.readouterr()
39-
assert 'love' in out
39+
assert 'the' in out
4040

4141

4242
def test_query_struct_params(capsys):

samples/snippets/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
google-cloud-bigquery==0.24.0
1+
google-cloud-bigquery==0.25.0
22
google-auth-oauthlib==0.1.0
33
pytz==2017.2

samples/snippets/resources/data.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Gandalf, 2000, 140.0, 1
1+
Gandalf,2000,140.0,1

samples/snippets/simple_app.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,10 @@ def query_shakespeare():
3838
# [END run_query]
3939

4040
# [START print_results]
41-
# Drain the query results by requesting a page at a time.
42-
page_token = None
41+
rows = query_results.fetch_data(max_results=10)
4342

44-
while True:
45-
rows, total_rows, page_token = query_results.fetch_data(
46-
max_results=10,
47-
page_token=page_token)
48-
49-
for row in rows:
50-
print(row)
51-
52-
if not page_token:
53-
break
43+
for row in rows:
44+
print(row)
5445
# [END print_results]
5546

5647

samples/snippets/sync_query.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,10 @@ def sync_query(query):
3939

4040
query_results.run()
4141

42-
# Drain the query results by requesting a page at a time.
43-
page_token = None
42+
rows = query_results.fetch_data(max_results=10)
4443

45-
while True:
46-
rows, total_rows, page_token = query_results.fetch_data(
47-
max_results=10,
48-
page_token=page_token)
49-
50-
for row in rows:
51-
print(row)
52-
53-
if not page_token:
54-
break
44+
for row in rows:
45+
print(row)
5546
# [END sync_query]
5647

5748

samples/snippets/user_credentials.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,11 @@ def run_query(credentials, project, query):
4646

4747
wait_for_job(query_job)
4848

49-
# Drain the query results by requesting a page at a time.
5049
query_results = query_job.results()
51-
page_token = None
50+
rows = query_results.fetch_data(max_results=10)
5251

53-
while True:
54-
rows, total_rows, page_token = query_results.fetch_data(
55-
max_results=10,
56-
page_token=page_token)
57-
58-
for row in rows:
59-
print(row)
60-
61-
if not page_token:
62-
break
52+
for row in rows:
53+
print(row)
6354

6455

6556
def authenticate_and_query(project, query, launch_browser=True):

0 commit comments

Comments
 (0)