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 TypeError if wrong job_config type is passed to client job methods (load_table_from_*, query, ...) #9480

Closed
tswast opened this issue Oct 15, 2019 · 4 comments · Fixed by #9506
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 Oct 15, 2019

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

It's a somewhat common problem to pass in a QueryJobConfig when you meant to create a LoadJobConfig. (I've done it!) This results in a difficult-to-debug error from the backend:

google.api_core.exceptions.BadRequest: 400 POST https://bigquery.googleapis.com/upload/bigquery/v2/projects/swast-scratch/jobs?uploadType=resumable: Required parameter is missing

Describe the solution you'd like

Instead, let's catch when someone passes in the wrong type to a job_config parameter and raise a ValueError with a more helpful message like: Expected a LoadJobConfig for the job_config parameter, but got job_config=....

Describe alternatives you've considered

  • Continue to let the server catch these errors. The error message is unfortunately very difficult to debug, though, because we are sending a job resource of ambiguous type to the API.
  • Fail somewhere else, such as when we create the resource to send to the API. This is more error-prone and gives us less ability to catch the error at the line that actually caused it.

Additional context

In response to internal issue 121343256.

@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 Oct 15, 2019
@tswast
Copy link
Contributor Author

tswast commented Oct 15, 2019

QLogic folks, this is a good issue for you all to tackle.

@plamut
Copy link
Contributor

plamut commented Oct 19, 2019

As discussed with @tswast on the chat, I can also tackle this, as I am doing some extra hours this weekend.

@HemangChothani Let me know if you have already started working on this in the meantime to not duplicate the work (I heard that it's fine to start working on this).

@plamut plamut assigned plamut and unassigned HemangChothani Oct 19, 2019
@HemangChothani
Copy link
Contributor

HemangChothani commented Oct 19, 2019 via email

@plamut
Copy link
Contributor

plamut commented Oct 19, 2019

Oh, good to know, thanks.

@plamut plamut assigned HemangChothani and unassigned plamut Oct 19, 2019
@plamut plamut changed the title BigQuery: raise ValueError if wrong job_config type is passed to client job methods (load_table_from_*, query, ...) BigQuery: raise TypeError if wrong job_config type is passed to client job methods (load_table_from_*, query, ...) Oct 23, 2019
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
3 participants