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

feat: allow cell magic body to be a $variable #1053

Merged
merged 8 commits into from
Nov 16, 2021
Prev Previous commit
Next Next commit
Refactor logic for extracting query variable
plamut committed Nov 10, 2021
commit e26e0a88716ff78b6ae3f702bdf217a811cf9e6e
8 changes: 4 additions & 4 deletions google/cloud/bigquery/magics/magics.py
Original file line number Diff line number Diff line change
@@ -602,12 +602,12 @@ def _cell_magic(line, query):

if query_var_name.isidentifier():
ip = IPython.get_ipython()
try:
query = ip.user_ns[query_var_name]
except KeyError:
query = ip.user_ns.get(query_var_name, ip) # ip serves as a sentinel

if query is ip:
raise NameError(
f"Unknown query, variable {query_var_name} does not exist."
) from None
)
else:
if not isinstance(query, (str, bytes)):
raise TypeError(