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: Hide error traceback in BigQuery cell magic #8808

Merged
merged 2 commits into from
Aug 1, 2019

Conversation

plamut
Copy link
Contributor

@plamut plamut commented Jul 30, 2019

Closes #6848.

This PR makes sure that long tracebacks are hidden on exceptions when using %%bigquery cell magic, and only the relevant info is printed out.

How to test

  • Run IPython from the virtualenv and load the %%bigquery cell magic:
    %load_ext google.cloud.bigquery
    
  • Run a query that triggers an error, e.g. a syntax error, unknown dataset, etc. Example:
    %%bigquery 
    SELECT 1 SELECT
    

Actual result (before the fix):
An error is printed out, including the full traceback of internal calls.

Expected result (after the fix):
Only the relevant error info is printed out, i.e. without the traceback, as the latter can be considered an internal detail of the cell magic.

Things to discuss

  • It might not be desirable for the exception to be swallowed and replaced with a simple output to stdout. Should not make any difference for users, unless some of them use %%bigquery cell magic programmatically?
    No, as no one should be using the %%bigquery magic outside of a Jupyter environment

The traceback is an internal detail of the IPython magic, the users
should only see the relevant error information.
@plamut plamut added the api: bigquery Issues related to the BigQuery API. label Jul 30, 2019
@plamut plamut requested a review from a team July 30, 2019 07:54
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 30, 2019
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.

Thanks. IMO, no one should be using the %%bigquery magic outside of a jupyter environment, so swallowing the exception is OK.

bigquery/google/cloud/bigquery/magics.py Outdated Show resolved Hide resolved
@plamut plamut requested a review from tswast July 31, 2019 09:12
@plamut plamut merged commit 6fc0de5 into googleapis:master Aug 1, 2019
@plamut plamut deleted the iss-6848 branch August 1, 2019 07:33
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: magic cell in IPython/Jupyter should hide bad query tracebacks
3 participants