impl(bigquery): add query method to client#5926
Conversation
There was a problem hiding this comment.
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.
| /// 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()) | ||
| } |
There was a problem hiding this comment.
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
- Documentation: Document all public items in crates that we publish with
///. Doctests describing usage are highly encouraged. (link)
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Towards #5844