-
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
feat(bigquery): check json_rows arg type in insert_rows_json() #10162
Conversation
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.
@tswast, maybe we should do the same thing for insert_rows()
? The situation in it is very close to insert_rows_json()
:
google-cloud-python/bigquery/google/cloud/bigquery/client.py
Lines 2345 to 2364 in cb32c36
def insert_rows(self, table, rows, selected_fields=None, **kwargs): | |
"""Insert rows into a table via the streaming API. | |
See | |
https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll | |
Args: | |
table (Union[ \ | |
google.cloud.bigquery.table.Table, \ | |
google.cloud.bigquery.table.TableReference, \ | |
str, \ | |
]): | |
The destination table for the row data, or a reference to it. | |
rows (Union[Sequence[Tuple], Sequence[dict]]): | |
Row data to be inserted. If a list of tuples is given, each | |
tuple should contain data for each schema field on the | |
current table and in the same order as the schema fields. If | |
a list of dictionaries is given, the keys must include all | |
required fields in the schema. Keys which do not correspond | |
to a field in the schema are ignored. |
@@ -2506,6 +2506,8 @@ def insert_rows_json( | |||
identifies the row, and the "errors" key contains a list of | |||
the mappings describing one or more problems with the row. | |||
""" | |||
if not isinstance(json_rows, collections_abc.Sequence): | |||
raise TypeError("json_rows argument should be a sequence of dicts") |
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.
Yes, that's a good idea. |
Fixes #10132