Skip to content
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

BigQuery: raise a TypeError if a dictionary is passed to insert_rows_json #10132

Closed
tswast opened this issue Jan 14, 2020 · 0 comments · Fixed by #10162
Closed

BigQuery: raise a TypeError if a dictionary is passed to insert_rows_json #10132

tswast opened this issue Jan 14, 2020 · 0 comments · Fixed by #10162
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tswast
Copy link
Contributor

tswast commented Jan 14, 2020

Is your feature request related to a problem? Please describe.

If I want to only insert a single row at a time into a table, it's easy to accidentally try something like:

json_row = {"col1": "hello", "col2": "world"}
errors = client.insert_rows_json(
    table,
    json_row
)

This results in a 400 BadRequest error from the API, because it expects a list of rows, not a single row.

Describe the solution you'd like

It's difficult to debug this situation from the API response, so it'd be better if we raised a client-side error for passing in the wrong type for json_rows.

Describe alternatives you've considered

Leave as-is and request a better server-side message. This may be difficult to do, as the error happens at a level above BigQuery, which translates JSON to Protobuf for internal use.

Additional context

This issue was encountered by a customer engineer, and it took me a bit of debugging to figure out the actual issue. I expect other customers will encounter this problem as well.

@tswast tswast added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: bigquery Issues related to the BigQuery API. labels Jan 14, 2020
@IlyaFaer IlyaFaer self-assigned this Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants