Skip to content

impl(bigquery): add query polling and complete query#5896

Open
alvarowolfx wants to merge 1 commit into
googleapis:mainfrom
alvarowolfx:impl-bq-query-poll
Open

impl(bigquery): add query polling and complete query#5896
alvarowolfx wants to merge 1 commit into
googleapis:mainfrom
alvarowolfx:impl-bq-query-poll

Conversation

@alvarowolfx

Copy link
Copy Markdown
Contributor

Towards #5844

@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Jun 16, 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 implements query polling capabilities in the BigQuery crate, introducing the Query::until_done method, a CompleteQuery handle, and a poll_query_results helper function that uses exponential backoff. It also adds comprehensive unit tests to verify these behaviors. The review feedback points out violations of the repository style guide regarding the use of unwrap() and expect() in production code within the polling helper, recommending proper error propagation instead.

Comment on lines +99 to +102
let backoff_policy = ExponentialBackoffBuilder::default()
.with_maximum_delay(std::time::Duration::from_secs(10))
.build()
.unwrap();

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.

medium

According to the Repository Style Guide, unwrap() should not be used in production code. Instead of panicking on failure, handle the error by mapping it to a QueryError and propagating it using the ? operator.

    let backoff_policy = ExponentialBackoffBuilder::default()
        .with_maximum_delay(std::time::Duration::from_secs(10))
        .build()
        .map_err(|e| {
            QueryError::Rpc {
                source: google_cloud_gax::error::Error::service(
                    google_cloud_gax::error::rpc::Status::default()
                        .set_code(google_cloud_gax::error::rpc::Code::Internal)
                        .set_message(format!("failed to build backoff policy: {e}")),
                ),
            }
        })?;
References
  1. No unwrap() or expect() in production code or examples (use ? or handle errors). (link)

let mut state = PollingState::default();

loop {
let job_ref = job_ref.expect("query job should have job reference at this point");

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.

medium

According to the Repository Style Guide, expect() should not be used in production code. Instead of panicking if the job reference is missing, return a QueryError explicitly.

Suggested change
let job_ref = job_ref.expect("query job should have job reference at this point");
let job_ref = job_ref.ok_or_else(|| {
QueryError::Rpc {
source: google_cloud_gax::error::Error::service(
google_cloud_gax::error::rpc::Status::default()
.set_code(google_cloud_gax::error::rpc::Code::InvalidArgument)
.set_message("query job should have job reference at this point"),
),
}
})?;
References
  1. No unwrap() or expect() in production code or examples (use ? or handle errors). (link)

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.13043% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.90%. Comparing base (d059878) to head (b49514e).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/bigquery/src/query/query_handle.rs 99.11% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #5896    +/-   ##
========================================
  Coverage   97.89%   97.90%            
========================================
  Files         233      234     +1     
  Lines       59202    59432   +230     
========================================
+ Hits        57958    58189   +231     
+ Misses       1244     1243     -1     

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

@alvarowolfx alvarowolfx marked this pull request as ready for review June 17, 2026 13:56
@alvarowolfx alvarowolfx requested a review from a team as a code owner June 17, 2026 13:56
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.

1 participant