Skip to content

Commit

Permalink
docs: update snippets.py to use query_and_wait (#1773)
Browse files Browse the repository at this point in the history
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕
  • Loading branch information
DevStephanie authored Jan 16, 2024
1 parent 1271b18 commit d90602d
Showing 1 changed file with 3 additions and 4 deletions.
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

0 comments on commit d90602d

Please sign in to comment.