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: add `job_id`, `location`, `project`, and `query_id` properties on `RowIterator` by tswast · Pull Request #1733 · googleapis/python-bigquery

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

Conversation

@tswast

@tswast tswast commented Nov 17, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

These can be used to recover the original job metadata when RowIterator is the result of a QueryJob. This will be especially important after #1722 where query_and_wait() won't return an actual QueryJob object.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • 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)

Towards internal issue 305260214 and related to #589
🦕

Sorry, something went wrong.

Uh oh!

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

All reactions
@tswast
feat: add job_id, location, project, and query_id properties …
1f9dd1e
…on `RowIterator`

These can be used to recover the original job metadata when `RowIterator` is
the result of a `QueryJob`.
@tswast
tswast requested review from a team and farhan0102 November 17, 2023 20:59
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery API. labels Nov 17, 2023
@tswast
tswast requested review from Linchin and chalmerlowe and removed request for farhan0102 November 17, 2023 21:00
Linchin
Linchin reviewed Nov 17, 2023
View reviewed changes
Comment thread google/cloud/bigquery/job/query.py Resolved

Uh oh!

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

Linchin
Linchin reviewed Nov 17, 2023
View reviewed changes
Comment thread google/cloud/bigquery/table.py Outdated
bqstorage_download = functools.partial(
_pandas_helpers.download_arrow_bqstorage,
self._project,
self._bqstorage_project,

@Linchin Linchin Nov 17, 2023

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.

Looks like we now have two possible project values, does this mean a RowIterator can correspond to different projects for storage APIs compared to other APIs?

Sorry, something went wrong.

Uh oh!

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

All reactions
Linchin
Linchin reviewed Nov 17, 2023
View reviewed changes
Comment thread google/cloud/bigquery/table.py
@property
def _bqstorage_project(self) -> Optional[str]:
"""GCP Project ID where BQ Storage API will bill to (if applicable)."""
client = self.client

@Linchin Linchin Nov 17, 2023

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.

I wonder what's the difference between self.client.project and self._project. When the client isn't of storage type, does self.client.project still reflect the storage project id?

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Nov 17, 2023 •
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 difference in other contexts is usually described as "billing project" versus "data project". I've renamed this private property to reflect that. This is easiest to understand in the context of public datasets.

I have permission to query tables in the bigquery-public-data project and even download the data in bulk with the BigQuery Storage Read API, but I don't have permission to run queries in that project or start a BigQuery Storage Read API session from that project. Instead, I have start the query or bq storage read session in my own project and reference the tables in the other project.

Sorry, something went wrong.

Uh oh!

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

All reactions

@Linchin Linchin Nov 17, 2023

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.

Wow I see! so self._project is the project for the data/table, and self.client.project a.k.a. billing project is the user's own project. So I guess this billing project doesn't just apply to storage?

Sorry, something went wrong.

Uh oh!

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

tswast reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@tswast tswast Nov 17, 2023

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.

That's true, though for queries we're using jobs.getQueryResults, so the project will always be the billing project since that's where temp results for queries are stored.

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Nov 17, 2023

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.

tabledata.list is free, but technically we should be overriding the x-goog-user-project header so that the quota is charged to the billing project. (I don't think we're actually doing that, though)

Sorry, something went wrong.

Uh oh!

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

All reactions
@tswast
rename bqstorage_project to billing project
18abf49
Linchin
Linchin reviewed Nov 17, 2023
View reviewed changes
Comment thread google/cloud/bigquery/table.py Resolved

Uh oh!

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

@tswast @Linchin
Update google/cloud/bigquery/table.py
1a07c4e
Co-authored-by: Lingqing Gan <[email protected]>
Linchin
Linchin approved these changes Nov 18, 2023
View reviewed changes
@Linchin
Linchin merged commit 494f275 into main Nov 18, 2023
@Linchin
Linchin deleted the b305260214-rowiterator-job-metadata branch November 18, 2023 00:44
@release-please release-please Bot mentioned this pull request Nov 18, 2023
chore(main): release 3.14.0 #1709
Merged
chalmerlowe
chalmerlowe reviewed Nov 19, 2023
View reviewed changes
Comment thread tests/unit/test_table.py

def test_job_id_missing(self):
rows = self._make_one()
self.assertIsNone(rows.job_id)

@chalmerlowe chalmerlowe Nov 19, 2023

Copy link
Copy Markdown
Collaborator

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.

@tswast

Just curious about testing philosophy.
For this collection of tests that are pretty much the same (i.e. all the tests that .assertIsNone()) is there a benefit in your mind to having each test broken out separately versus providing a parameterized list of inputs and expected outputs?

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Nov 20, 2023

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.

I matched the existing pattern in this test. I do think we could probably combine a lot of these into a single parametrized test.

I worry slightly about the required getattr(property_name) being too complex for new contributors to understand. In general tests should avoid anything even as complex as an if statement. https://testing.googleblog.com/2014/07/testing-on-toilet-dont-put-logic-in.html In this case, getattr is a grey area. I wouldn't necessarily count it as "logic"

Sorry, something went wrong.

Uh oh!

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

All reactions
kiraksi pushed a commit to kiraksi/python-bigquery that referenced this pull request Nov 20, 2023
@tswast @Linchin @kiraksi
feat: add job_id, location, project, and query_id properties …
570e17a
…on `RowIterator` (googleapis#1733)

* feat: add `job_id`, `location`, `project`, and `query_id` properties on `RowIterator`

These can be used to recover the original job metadata when `RowIterator` is
the result of a `QueryJob`.

* rename bqstorage_project to billing project

* Update google/cloud/bigquery/table.py

Co-authored-by: Lingqing Gan <[email protected]>

---------

Co-authored-by: Lingqing Gan <[email protected]>
This was referenced Dec 5, 2023
December 04, 2023 kitta65/bq-extension-vscode#257
Closed
December 04, 2023 kitta65/prettier-plugin-bq#264
Closed
December 04, 2023 kitta65/bq2cst#274
Closed
This was referenced Dec 19, 2023
December 18, 2023 kitta65/bq-extension-vscode#262
Closed
December 18, 2023 kitta65/prettier-plugin-bq#269
Closed
December 18, 2023 kitta65/bq2cst#279
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@chalmerlowe chalmerlowe chalmerlowe left review comments
@Linchin Linchin Linchin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@tswast @chalmerlowe @Linchin
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.