Skip to content

impl(bigquery): add query runner builder#5870

Open
alvarowolfx wants to merge 9 commits into
googleapis:mainfrom
alvarowolfx:impl-bq-run-query
Open

impl(bigquery): add query runner builder#5870
alvarowolfx wants to merge 9 commits into
googleapis:mainfrom
alvarowolfx:impl-bq-run-query

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 10, 2026

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

Copy link
Copy Markdown

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 custom error handling and query execution scaffolding for the Cloud BigQuery query client, including a new QueryError enum and a unified RunQuery request builder. The review feedback highlights opportunities to optimize performance and simplify the design by removing unnecessary String clones when values are consumed, and eliminating a redundant Arc wrapper around the underlying RPC error since QueryError does not implement Clone.

Comment thread src/bigquery/src/query/run_query.rs Outdated
Comment thread src/bigquery/src/query/run_query.rs Outdated
Comment thread src/bigquery/src/error.rs
Comment thread src/bigquery/src/error.rs
@alvarowolfx alvarowolfx marked this pull request as ready for review June 10, 2026 20:41
@alvarowolfx alvarowolfx requested a review from a team as a code owner June 10, 2026 20:41
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.88%. Comparing base (75137ab) to head (1c4d32f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5870   +/-   ##
=======================================
  Coverage   97.88%   97.88%           
=======================================
  Files         230      231    +1     
  Lines       58104    58192   +88     
=======================================
+ Hits        56875    56964   +89     
+ Misses       1229     1228    -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.

Comment thread src/bigquery/src/generated/run_query_request.rs
@alvarowolfx alvarowolfx changed the title impl(bigquery): add query runner builder and query errors impl(bigquery): add query runner builder Jun 11, 2026
@alvarowolfx

Copy link
Copy Markdown
Contributor Author

issues on this PR will be solved when #5874 is merged and also I split errors to be merged on a separated PR: #5873

@dbolduc dbolduc left a comment

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.

I think the new() should be pub(crate), but nothing else is blocking.

Comment on lines +38 to +40
request: RunQueryRequest::default()
.set_query(sql)
.set_use_legacy_sql(wkt::BoolValue::from(false)),

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.

non-blocking Q: default to job creation mode optional?


impl RunQuery {
/// Creates a new `RunQuery` builder for the given SQL query.
pub fn new(job_service: Arc<JobService>, sql: String) -> Self {

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.

nit: pub(crate) ?

Comment on lines +80 to +81
include!("../generated/run_query_builder.rs");
include!("../generated/run_query_request.rs");

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.

style comment: we should prefer to have a mod generated over include!(), e.g.: https://github.com/googleapis/google-cloud-rust/blob/main/src/storage/src/generated.rs

The compiler can do smarter things if we build the module tree vs. pasting code in. (I think, I could understand the why better).

I think you would have to mess around with the modules of the generated types though, so feel free to take a TODO and not block this PR.

let mut run_query = RunQuery::new(job_service, "SELECT 1".to_string());
assert!(!run_query.request.force_job_path());

// Set allow_large_results

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.

remove? comment is not adding to the code.

Comment on lines +51 to +52
/// Executes the SQL query, routing internally to `jobs.query` (fast path)
/// or `jobs.insert` (job path) depending on configured fields.

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.

nit:

Suggested change
/// Executes the SQL query, routing internally to `jobs.query` (fast path)
/// or `jobs.insert` (job path) depending on configured fields.
/// Executes the SQL query
///
/// The implementation routes internally to `jobs.query` (fast path)
/// or `jobs.insert` (job path) depending on configured fields. If the fast path is available, the client library takes it. If not, it falls back to creating a job, which is typically slower.

^ probably need to reformat. And links are helpful.

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