Skip to content

Commit d90602d

Browse files
authored
docs: update snippets.py to use query_and_wait (#1773)
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://togithub.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> 🦕
1 parent 1271b18 commit d90602d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docs/snippets.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,12 @@ def test_client_query_total_rows(client, capsys):
465465
'WHERE state = "TX" '
466466
"LIMIT 100"
467467
)
468-
query_job = client.query(
468+
results = client.query_and_wait(
469469
query,
470470
# Location must match that of the dataset(s) referenced in the query.
471471
location="US",
472-
) # API request - starts the query
472+
) # API request - starts the query and waits for results.
473473

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

@@ -551,7 +550,7 @@ def test_query_results_as_dataframe(client):
551550
LIMIT 10
552551
"""
553552

554-
df = client.query(sql).to_dataframe()
553+
df = client.query_and_wait(sql).to_dataframe()
555554
# [END bigquery_query_results_dataframe]
556555
assert isinstance(df, pandas.DataFrame)
557556
assert len(list(df)) == 2 # verify the number of columns

0 commit comments

Comments
 (0)