Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update snippets.py to use query_and_wait #1773

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,12 @@ def test_client_query_total_rows(client, capsys):
'WHERE state = "TX" '
"LIMIT 100"
)
query_job = client.query(
results = client.query_and_wait(
query,
# Location must match that of the dataset(s) referenced in the query.
location="US",
) # API request - starts the query
) # API request - starts the query and waits for results.

results = query_job.result() # Wait for query to complete.
print("Got {} rows.".format(results.total_rows))
# [END bigquery_query_total_rows]

Expand Down Expand Up @@ -551,7 +550,7 @@ def test_query_results_as_dataframe(client):
LIMIT 10
"""

df = client.query(sql).to_dataframe()
df = client.query_and_wait(sql).to_dataframe()
# [END bigquery_query_results_dataframe]
assert isinstance(df, pandas.DataFrame)
assert len(list(df)) == 2 # verify the number of columns
Expand Down