GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: allow cell magic body to be a $variable by plamut · Pull Request #1053 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@plamut

@plamut plamut commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

Closes #1040.

Thought - we probably want to follow up with a sample demonstrating this new use case.

Also, the length of the _cell_magic() function should be ignored for now, it's been waiting to be split into smaller units since forever. 🙂

PR checklist:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut
feat: allow cell magic body to be a $variable
c16fde3
@plamut
plamut requested review from a team and loferris November 8, 2021 19:45
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 8, 2021
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Nov 8, 2021
tseaver
tseaver reviewed Nov 8, 2021
View reviewed changes
Comment thread google/cloud/bigquery/magics/magics.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/bigquery/magics/magics.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@google-cla

google-cla Bot commented Nov 8, 2021

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@google-cla google-cla Bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Nov 8, 2021
@tseaver

tseaver commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

@googlebot I consent.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@google-cla

google-cla Bot commented Nov 8, 2021

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

@plamut Sorry, I tried. :-<

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut

plamut commented Nov 8, 2021

Copy link
Copy Markdown
Contributor Author

OK, I'll edit the commit message then to silence the bot.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut
Fix missing indefinitive article in error msg
e5610d6
@plamut
plamut force-pushed the iss-1040 branch from 86ea1cf to e5610d6 Compare November 8, 2021 20:15
@google-cla google-cla Bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Nov 8, 2021
plamut and others added 2 commits November 8, 2021 22:25
@plamut
Adjust test assertion to error message change
e9fd366
@plamut
Merge branch 'main' into iss-1040
ebd3228
tseaver
tseaver approved these changes Nov 9, 2021
View reviewed changes
@tswast tswast assigned loferris Nov 9, 2021
plamut added 2 commits November 10, 2021 22:02
@plamut
Merge branch 'main' into iss-1040
6c170e4
@plamut
Refactor logic for extracting query variable
e26e0a8
loferris
loferris reviewed Nov 10, 2021
View reviewed changes
Comment thread tests/unit/test_magics.py
cell_body = "$custom_query"

with pytest.raises(
NameError, match=r".*custom_query does not exist.*"

@loferris loferris Nov 10, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe comment to indicate we're testing the first kind of error, as I got the regex string match from context of the other file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@plamut plamut Nov 10, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The name of the test explains which case it covers ("non-existing query variable"), do you think that's not sufficient by itself?

I always look at the name of the test first, although it might be just how my brain is wired...

Update: Added a comment next to the assignment to cell_body to explain which use case it targets.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@loferris loferris Nov 16, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM - I really like how you added the "non-existing query variable" condition.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

plamut reacted with heart emoji
All reactions
  • ❤️ 1 reaction
loferris
loferris approved these changes Nov 10, 2021
View reviewed changes

@loferris loferris left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM - could do with more comments on test cases, perhaps.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/test_magics.py
cell_body = "$custom_query"

with pytest.raises(
TypeError, match=r".*must be a string or a bytes-like.*"

@loferris loferris Nov 10, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Might be good to have another comment here to match it to the other else condition in run_query_magic

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/test_magics.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@plamut
Explicitly warn about missing query variable name
88e1638
@plamut plamut added the automerge Merge the pull request once unit tests and other checks pass. label Nov 11, 2021
@plamut
Thest the query "variable" is not identifier case
b6d43c1
@plamut plamut removed the automerge Merge the pull request once unit tests and other checks pass. label Nov 11, 2021
@plamut
plamut requested a review from loferris November 11, 2021 10:17
@loferris

loferris commented Nov 16, 2021

Copy link
Copy Markdown
Contributor

LGTM - appreciate the changes!!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

loferris
loferris approved these changes Nov 16, 2021
View reviewed changes
@plamut
plamut merged commit 3a681e0 into googleapis:main Nov 16, 2021
@plamut
plamut deleted the iss-1040 branch November 16, 2021 21:57
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release python-bigquery 1.27.1 #1097
Closed
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this pull request Apr 17, 2023
@plamut @abdelmegahedgoogle
feat: allow cell magic body to be a $variable (googleapis#1053)
05df4c2
* feat: allow cell magic body to be a $variable

* Fix missing indefinitive article in error msg

* Adjust test assertion to error message change

* Refactor logic for extracting query variable

* Explicitly warn about missing query variable name

* Thest the query "variable" is not identifier case
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@tseaver tseaver tseaver approved these changes
@loferris loferris loferris approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@loferris loferris

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@plamut @tseaver @loferris
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.