google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

[Documentation Issue] table.fetch_data(max_results=100)

Open mchirico opened this issue 10 years ago • 2 comments

Page Name: bigquery-usage Release: a1b8066

Please note, the following documentation appears to be incorrect. https://googlecloudplatform.github.io/gcloud-python/latest/bigquery-usage.html

Get rows from a table’s data:

from gcloud import bigquery
>>> client = bigquery.Client()
>>> dataset = client.dataset('dataset_name')
>>> table = dataset.table(name='person_ages')
>>> rows, next_page_token = table.fetch_data(max_results=100)  # API request
>>> for row in rows:
...     for field, value in zip(table.schema, row):
...         do_something(field, value)

Specifically the following line of code returns 3 values. It appears that total_rows is missing.

rows, next_page_token = table.fetch_data(max_results=100)  # API request

The documentation for table.fetch_data states the following:

returns: ``(row_data, total_rows, page_token)``, where ``row_data``
              is a list of tuples, one per result row, containing only
              the values;  ``total_rows`` is a count of the total number
              of rows in the table;  and ``page_token`` is an opaque

mchirico avatar Jul 13 '16 11:07 mchirico

Thanks for reporting! Let me know if I missed anything in #1981.

daspecster avatar Jul 13 '16 20:07 daspecster

Closed via #1833.

tseaver avatar Jul 13 '16 23:07 tseaver