Skip to content

impl(bigquery): remove QueryReference in favor of QueryCreationMetadata - #6317

Merged
alvarowolfx merged 1 commit into
googleapis:mainfrom
alvarowolfx:impl-bq-rm-query-reference
Aug 10, 2026
Merged

impl(bigquery): remove QueryReference in favor of QueryCreationMetadata#6317
alvarowolfx merged 1 commit into
googleapis:mainfrom
alvarowolfx:impl-bq-rm-query-reference

Conversation

@alvarowolfx

Copy link
Copy Markdown
Contributor

Previously was assumed that QueryID and JobID were mutually exclusive (they're once, but now it isn't anymore). QueryReference was created with that in mind, so it doesn't make sense anymore and customers can access QueryID and JobID via QueryCreationMetadata now, giving access to the full RPC responses, without additional abstractions.

Towards #5844

@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Aug 10, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the BigQuery query API by removing the QueryReference enum and its associated query_reference() method. Instead, it introduces a metadata() method on the Query struct that returns a reference to QueryCreationMetadata, allowing direct access to fields like query_id and job_reference. All examples, tests, and internal usages have been updated to align with this simplified design. I have no additional feedback to provide as the changes are clean and idiomatic.

@alvarowolfx
alvarowolfx marked this pull request as ready for review August 10, 2026 15:54
@alvarowolfx
alvarowolfx requested a review from a team as a code owner August 10, 2026 15:54
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.26%. Comparing base (af7c971) to head (6d158eb).

Files with missing lines Patch % Lines
src/bigquery/src/query/query_handle.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6317      +/-   ##
==========================================
- Coverage   96.27%   96.26%   -0.01%     
==========================================
  Files         283      282       -1     
  Lines       73333    73278      -55     
==========================================
- Hits        70599    70541      -58     
- Misses       2734     2737       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +38 to +44
if !metadata.query_id.is_empty() {
println!(
"Query was run in optional job mode. Query ID: \"{}\"",
metadata.query_id
);
}
if let Some(job) = &metadata.job_reference {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment: it is a tiny bit sad that the mutual exclusivity of these things is not encoded in the type. I think it's fine though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, unfortunately was an error from the service side to not declared it nullable. It's a hard call to us to add an override to change the type, even that I would like to.

Comment thread tests/bigquery/src/lib.rs
Comment on lines +238 to +239
let query_id = &metadata.query_id;
assert!(!query_id.is_empty(), "expected non-empty query_id");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

optional nit:

Suggested change
let query_id = &metadata.query_id;
assert!(!query_id.is_empty(), "expected non-empty query_id");
assert!(!metadata.query_id.is_empty(), "expected non-empty query_id");

@alvarowolfx
alvarowolfx merged commit 4ff2683 into googleapis:main Aug 10, 2026
41 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants