Skip to content

impl(bigquery): add attach_job method to query client - #6295

Open
haphungw wants to merge 2 commits into
googleapis:mainfrom
haphungw:feat-bq-attach-job
Open

impl(bigquery): add attach_job method to query client#6295
haphungw wants to merge 2 commits into
googleapis:mainfrom
haphungw:feat-bq-attach-job

Conversation

@haphungw

@haphungw haphungw commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Add BigQuery::attach_job to bind an existing out-of-process query job reference (JobReference) to a high-level Query handle without re-submitting SQL.

@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Aug 5, 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 introduces the ability to configure a default Google Cloud project ID on the BigQuery client and adds an attach_job method to bind existing out-of-process query jobs. The feedback recommends refactoring the nested if-else block in attach_job using Rust's let-else syntax to reduce indentation, and replacing .unwrap() calls with .expect() in the new unit tests to adhere to the repository's style guide.

Comment thread src/bigquery/src/client.rs
Comment thread src/bigquery/src/client.rs Outdated
Comment thread src/bigquery/src/client.rs Outdated
@haphungw
haphungw force-pushed the feat-bq-attach-job branch from 9ebfb67 to f6fa4f4 Compare August 5, 2026 22:02
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.27%. Comparing base (e71018a) to head (30216c5).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6295   +/-   ##
=======================================
  Coverage   96.26%   96.27%           
=======================================
  Files         283      283           
  Lines       73009    73096   +87     
=======================================
+ Hits        70279    70370   +91     
+ Misses       2730     2726    -4     

☔ 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.

@haphungw
haphungw force-pushed the feat-bq-attach-job branch from f6fa4f4 to 7f66bb6 Compare August 7, 2026 21:42
@haphungw
haphungw marked this pull request as ready for review August 7, 2026 21:45
@haphungw
haphungw requested a review from a team as a code owner August 7, 2026 21:45
@haphungw
haphungw requested a review from alvarowolfx August 10, 2026 15:49
Comment thread src/bigquery/src/error.rs Outdated

/// An invalid job reference was provided.
#[error("invalid job reference: {0}")]
InvalidJobReference(String),

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.

I’m a little unsure about InvalidJobReference(String) here. Since the only validation failure we currently handle is a missing job_id, it feels more consistent with MissingProjectId to add a specific MissingJobId variant instead of a more generic error. Are there other errors that we are expecting will be encapsulated by this type?

Comment thread src/bigquery/src/error.rs Outdated

/// An invalid job reference was provided.
#[error("invalid job reference: {0}")]
InvalidJobReference(String),

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.

I'm not sure if we should introduce another branch for missing information for Job. Maybe we should bundle MissingProjectId and InvalidJobReference into a BindingError ? I think that's how it's done in other veneers. Will check here and come back to that.

@haphungw

haphungw commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@suzmue @alvarowolfx
I agree we should consolidate these.

I checked gaxi BindingError, but it seems to be a group of REST URL routing failures (like PathMismatch). It would be pretty awkward to construct for simple manual struct validation here.

To keep things clean, I merged MissingProjectId and InvalidJobReference into QueryError::InvalidArgument(String). This covers both missing project and job IDs (and potential future errors) without cluttering the enum.

@dbolduc

dbolduc commented Aug 10, 2026

Copy link
Copy Markdown
Member

(drive by)

I checked gaxi BindingError, but it seems to be a group of REST URL routing failures (like PathMismatch).

True. Calling it Path was probably a failure to generalize from me.

It would be pretty awkward to construct for simple manual struct validation here.

It's bad but not sooo bad: https://github.com/googleapis/google-cloud-rust/pull/6253/changes

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.

4 participants