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

allow the body of %%bigquery cell magic to be a $variable #1040

Closed
tswast opened this issue Nov 1, 2021 · 1 comment · Fixed by #1053
Closed

allow the body of %%bigquery cell magic to be a $variable #1040

tswast opened this issue Nov 1, 2021 · 1 comment · Fixed by #1053
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tswast
Copy link
Contributor

tswast commented Nov 1, 2021

Is your feature request related to a problem? Please describe.

When using BigQuery notebooks. There are queries that would be nice to be parametrized, but the parameters are in places where BigQuery parameterized queries don't work. For example, you can't parametrize the table ID.

Describe the solution you'd like

When a $variable is the only thing in the query body, replace it with the value from the variable in Python. This is similar to how the first %%bigquery line works.

Cell 1

yourprojectid = "swast-scratch"
query = "SELECT * FROM something"

Cell 2

%%bigquery --project $yourprojectid
$query

Describe alternatives you've considered

One could try and find any $variable in the query body, but this would be a breaking change.

Additional context

Currently the %%bigquery has some logic to see if the body is a table ID or a full query. We should retain this logic, and it should happen after the replacement of the variable. Detecting if the body is only a $variable should be similar to the detection of if the body is only a table ID.

Feature request is from an email thread "python magics - fully parameterized query" with @minhaz and @shollyman

@tswast tswast added api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 1, 2021
@plamut
Copy link
Contributor

plamut commented Nov 7, 2021

I have some free cycles next week, is this already in progress or just assigned for now?
Thanks! 🙂

Update: Discussed offline, I can handle this and then move on to some v3 issues, and can assign Lo as a reviewer for onboarding purposes.

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 googleapis/python-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