Skip to content

BigQuery: raise TypeError if wrong job_config type is passed to client job methods (load_table_from_*, query, ...) #9480

Closed
@tswast

Description

@tswast

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.

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions