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: Include SQL query and job ID in job errors #8748

Merged
merged 3 commits into from
Jul 26, 2019

Conversation

plamut
Copy link
Contributor

@plamut plamut commented Jul 24, 2019

Closes #5408.

As per user request, this PR adds additional info to any errors that might happen when calling job.result().

How to test

  • Use BigQuery client to run a query that results in an error - e.g. invalid SQL syntax, unknown table/dataset, etc.

Actual result (before the fix):
The error output only contains the exception traceback.

Actual result (after the fix):
The error output contains all of the following: exception traceback, job ID, the SQL query itself with lines enumerated. The type of the exception with the modified message is the same as the original exception type.

@plamut plamut added the api: bigquery Issues related to the BigQuery API. label Jul 24, 2019
@plamut plamut requested a review from a team July 24, 2019 22:38
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 24, 2019
@plamut
Copy link
Contributor Author

plamut commented Jul 24, 2019

Again, one of the unit tests will fail (converting special float to arrow), but it is not related to this PR.

@tseaver
Copy link
Contributor

tseaver commented Jul 25, 2019

Looks like we might need to pin one of the dependencies (pyarrow?) to fix our tests.

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job with the rulers. I like it! One nit-pick re: header for the SQL.

bigquery/google/cloud/bigquery/job.py Outdated Show resolved Hide resolved
The code for query format in exception messages is a modified version
of the original proposal by @bencaine1 in the feature request:

googleapis#5408 (comment)
All GoogleAPICallError (GoogleCloudError) instances have the "message"
attribute, even in Python 3, thus the additional info can be appended
directly to that attribute.
It's not always the query that causes the error, thus this commit
makes the header text more neutral.
@tswast tswast merged commit d295ec5 into googleapis:master Jul 26, 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. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigQuery: Print offending SQL on error with QueryJob.result()
4 participants