Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 473fd9d

Browse filesBrowse files
committed
BQ: Use futures API for quickstart.
1 parent 1e79287 commit 473fd9d
Copy full SHA for 473fd9d

File tree

Expand file treeCollapse file tree

1 file changed

+8
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-6
lines changed

‎bigquery/cloud-client/simple_app.py

Copy file name to clipboardExpand all lines: bigquery/cloud-client/simple_app.py
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,31 @@
1717
"""Simple application that performs a query with BigQuery."""
1818
# [START all]
1919
# [START create_client]
20+
import uuid
21+
2022
from google.cloud import bigquery
2123

2224

2325
def query_shakespeare():
2426
client = bigquery.Client()
2527
# [END create_client]
2628
# [START run_query]
27-
# See: https://cloud.google.com/bigquery/sql-reference/
28-
query_results = client.run_sync_query("""
29+
query_job = client.run_async_query(str(uuid.uuid4()), """
2930
#standardSQL
3031
SELECT corpus AS title, COUNT(*) AS unique_words
3132
FROM `publicdata.samples.shakespeare`
3233
GROUP BY title
3334
ORDER BY unique_words DESC
3435
LIMIT 10""")
3536

36-
query_results.run()
37+
query_job.begin()
38+
query_job.result() # Wait for job to complete.
3739
# [END run_query]
3840

3941
# [START print_results]
40-
rows = query_results.fetch_data()
41-
42-
for row in rows:
42+
destination_table = query_job.destination
43+
destination_table.reload()
44+
for row in destination_table.fetch_data():
4345
print(row)
4446
# [END print_results]
4547

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.