- Notifications
You must be signed in to change notification settings - Fork1.6k
Add sample for fetching total_rows from query results.#7217
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
bigquery/docs/snippets.py Outdated
| results=query_job.result()# Waits for query to complete. | ||
| next(iter(results))# Fetch the first page of results, which contains total_rows. | ||
| print("Got {} rows.".format(results.total_rows)) | ||
| # [START bigquery_query_total_rows] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
END?
bigquery/docs/snippets.py Outdated
| deftest_client_query_total_rows(client,capsys): | ||
| """Run a query an just check for how many rows.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
s/an/and/
yan-hic commentedJan 30, 2019
Would fetching the first page of |
tswast commentedJan 30, 2019
@yiga2 Calling I agree that the way I show in this sample is a bit awkward, and I was thinking about fetching the first page automatically in#4152, but I changed my mind about prefetching, since it could mean an extra unnecessary API request if someone just cares that a query completes and not the actual result rows. Perhaps we could find a way to pass the |
yan-hic commentedMar 15, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@tswast any further consideration on getting |
tswast commentedMar 15, 2019
@yiga2 I still think it's a good idea. I just haven't gotten around to. We're open to PRs. The change would likely be to the |
yan-hic commentedMar 18, 2019
@tswast Feel free to bundle with other enhancements as PR would be very light otherwise. Suggested code change, after
total_rows = self._query_results.total_rows |
yan-hic commentedApr 3, 2019
@tswast any feedback on this ? |
tswast commentedApr 3, 2019
@yiga2 I've prepared#7622 which addresses this issue, but in a slightly more complicated way than we propose here because I wanted to also handle more cases where |
yan-hic commentedApr 3, 2019
Cool - thanks Tim ! |
In response to feedback internally Bug 123578325, add a sample (acts as a system test, too) which shows how to populate the
total_rowsvalue.