-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Move BigQuery list_ methods to use iterators #2565
Conversation
@@ -72,7 +72,7 @@ | |||
} | |||
TEST_RC_REPLACEMENTS = { | |||
'FORMAT': { | |||
'max-module-lines': 1960, | |||
'max-module-lines': 2000, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
page_token=page_token, max_results=max_results, | ||
page_start=_rows_page_start) | ||
iterator.schema = self._schema | ||
# Over-ride the key used to retrieve the next page token. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -86,20 +86,34 @@ def _string_from_json(value, _): | |||
} | |||
|
|||
|
|||
def _row_from_json(row, schema): | |||
"""Convert JSON row data to row w/ appropriate types. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"""Convert JSON row data to row w/ appropriate types. | ||
|
||
:type row: dict | ||
:param row: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return _row_from_json(resource, iterator.schema) | ||
|
||
|
||
# pylint: disable=unused-argument |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
max_results=MAX, | ||
page_token=TOKEN) | ||
iterator = table.fetch_data( | ||
client=client2, max_results=MAX, page_token=TOKEN) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@tseaver Can you weigh in here? I'm especially curious how you feel about |
+0 for adding it to -1 for adding it to |
Check out the implementation, I put |
""" | ||
total_rows = response.get('totalRows') | ||
if total_rows is not None: | ||
page.total_rows = int(total_rows) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM, once you decide about my question about where |
@tseaver I'll put |
@tseaver I started writing the code to put Given this scenario, it seems like |
@dhermes For queries, the docs say For tables, the docs say only that |
@fhoffa Can you chime in on how stable the |
In particular, isolating the logic useful to work on a single row.
e439de8
to
d3a6dff
Compare
Also fixing BigQuery system test in the process.
@tseaver I put |
Move BigQuery list_ methods to use iterators
Follow up to #2561. This only covers
Dataset.list_tables()
andTable.fetch_data()
. It may also be "correct" to use an Iterator inQueryResults.fetch_data
QueryResults.run
(viaQueryResults._build_resource
)but I wanted to get eyes on this change first / opinion from the original author (@tseaver) before moving forward.