Skip to content

impl(bigquery): add query method to client#5926

Draft
alvarowolfx wants to merge 1 commit into
googleapis:mainfrom
alvarowolfx:impl-bq-query-fn
Draft

impl(bigquery): add query method to client#5926
alvarowolfx wants to merge 1 commit into
googleapis:mainfrom
alvarowolfx:impl-bq-query-fn

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 22, 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 a unified query method to the BigQuery client to prepare SQL query executions, and publicly exposes QueryReference. The review feedback suggests adding a doctest to the new public query method to comply with the repository's style guide on documenting public items.

Comment on lines +61 to +66
/// Prepares a SQL query execution by returning a unified `RunQuery` request builder.
/// This builder internally routes to either `jobs.query` (fast path) or `jobs.insert` (job path)
/// depending on the fields configured.
pub fn query<S: Into<String>>(&self, sql: S) -> RunQuery {
RunQuery::new(self.job_service.clone(), sql.into())
}

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

The repository style guide highly encourages adding doctests describing usage for all public items. Adding a doctest to the query method will improve usability and serve as a clear example for developers.

    /// Prepares a SQL query execution by returning a unified `RunQuery` request builder.
    /// This builder internally routes to either `jobs.query` (fast path) or `jobs.insert` (job path)
    /// depending on the fields configured.
    ///
    /// # Example
    ///
    /// ```rust,no_run
    /// # use google_cloud_bigquery::client::BigQuery;
    /// # #[tokio::main]
    /// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
    /// let client = BigQuery::builder().build().await?;
    /// let query = client.query("SELECT 1")
    ///     .with_project_id("my-project")
    ///     .run()
    ///     .await?;
    /// # Ok(())
    /// # }
    /// ```
    pub fn query<S: Into<String>>(&self, sql: S) -> RunQuery {
        RunQuery::new(self.job_service.clone(), sql.into())
    }
References
  1. Documentation: Document all public items in crates that we publish with ///. Doctests describing usage are highly encouraged. (link)

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.89%. Comparing base (75c4db2) to head (b8dbe7f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/bigquery/src/client.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5926      +/-   ##
==========================================
- Coverage   97.90%   97.89%   -0.01%     
==========================================
  Files         234      234              
  Lines       59940    59943       +3     
==========================================
- Hits        58683    58682       -1     
- Misses       1257     1261       +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.

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