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: magic cell in IPython/Jupyter should hide bad query tracebacks #6848

Closed
brianquinlan opened this issue Dec 5, 2018 · 0 comments · Fixed by #8808
Closed

BigQuery: magic cell in IPython/Jupyter should hide bad query tracebacks #6848

brianquinlan opened this issue Dec 5, 2018 · 0 comments · Fixed by #8808
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

@brianquinlan
Copy link
Contributor

Incorrect user queries using IPython/Jupyter magic cells generate a large traceback. For example:

In [1]:  %%bigquery
           SELECT badname
           FROM mytable
---------------------------------------------------------------------------
BadRequest                                Traceback (most recent call last)
<ipython-input-4-f03917bb6736> in <module>
----> 1 get_ipython().run_cell_magic('bigquery', '', 'SELECT badname\nFROM mytable\n')

~/cloud/bigmerge/venv/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2321             magic_arg_s = self.var_expand(line, stack_depth)
   2322             with self.builtin_trap:
-> 2323                 result = fn(magic_arg_s, cell)
   2324             return result
   2325 

~/cloud/bigmerge/venv/lib/python3.6/site-packages/google/cloud/bigquery/magics.py in _cell_magic(line, query)
    322     job_config.query_parameters = params
    323     job_config.use_legacy_sql = args.use_legacy_sql
--> 324     query_job = _run_query(client, query, job_config)
    325 
    326     if not args.verbose:

~/cloud/bigmerge/venv/lib/python3.6/site-packages/google/cloud/bigquery/magics.py in _run_query(client, query, job_config)
    251             time.time() - start_time), end='')
    252         try:
--> 253             query_job.result(timeout=0.5)
    254             break
    255         except futures.TimeoutError:

~/cloud/bigmerge/venv/lib/python3.6/site-packages/google/cloud/bigquery/job.py in result(self, timeout, retry)
   2735             not complete in the given timeout.
   2736         """
-> 2737         super(QueryJob, self).result(timeout=timeout)
   2738         # Return an iterator instead of returning the job.
   2739         if not self._query_results:

~/cloud/bigmerge/venv/lib/python3.6/site-packages/google/cloud/bigquery/job.py in result(self, timeout)
    697             self._begin()
    698         # TODO: modify PollingFuture so it can pass a retry argument to done().
--> 699         return super(_AsyncJob, self).result(timeout=timeout)
    700 
    701     def cancelled(self):

~/cloud/bigmerge/venv/lib/python3.6/site-packages/google/api_core/future/polling.py in result(self, timeout)
    125             # pylint: disable=raising-bad-type
    126             # Pylint doesn't recognize that this is valid in this case.
--> 127             raise self._exception
    128 
    129         return self._result

BadRequest: 400 Unrecognized name: badname at [1:8]

Since the above code is executed implicitly, it should be hidden from the user and, instead, only the user-relevant part of the error should be shown. Like:

In [1]:  %%bigquery
           SELECT badname
           FROM mytable

Your query contained an error. Unrecognized name: badname at [1:8]
@tseaver tseaver changed the title [BigQuery] BigQuery magic cell in IPython/Jupyter should hide bad query tracebacks BigQuery: magic cell in IPython/Jupyter should hide bad query tracebacks Dec 5, 2018
@tseaver tseaver added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: bigquery Issues related to the BigQuery API. labels Dec 5, 2018
@alixhami alixhami self-assigned this Dec 20, 2018
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.

3 participants