GCP BigQuery Client
An ergonomic Rust async client library for GCP BigQuery.
- Support all BigQuery API endpoints (not all covered by unit tests yet)
- Support Service Account Key authentication, workload identity and other yup-oauth2 mechanisms
- Create tables and rows via builder patterns
- Persist complex Rust structs in structured BigQuery tables
- Async API
Features:
- rust-tls (default): RUSTLS-based
- native-tls: OpenSSL-based
Example
This example performs the following operations:
- Load a set of environment variables to set
$PROJECT_ID
,$DATASET_ID
,$TABLE_ID
and$GOOGLE_APPLICATION_CREDENTIALS
- Init the BigQuery client
- Create a dataset in the GCP project
$PROJECT_ID
- Create a table in the previously created dataset (table schema)
- Insert a set of rows in the previously created table via the BigQuery Streaming API. The inserted rows are based on a regular Rust struct implementing the trait Serialize.
- Perform a select query on the previously created table
- Drop the table previously created
- Drop the dataset previously created
let client = from_service_account_key_file.await;
// Create a new dataset
let dataset = client
.dataset
.create
.await?;
// Create a new table
let table = dataset
.create_table
.await?;
println!;
// Insert data via BigQuery Streaming API
let mut insert_request = new;
insert_request.add_row?;
insert_request.add_row?;
insert_request.add_row?;
insert_request.add_row?;
client
.tabledata
.insert_all
.await?;
// Query
let mut rs = client
.job
.query
.await?;
while rs.next_row
// Delete the table previously created
client.table.delete.await?;
// Delete the dataset previously created
client.dataset.delete.await?;
Status
The API of this crate is still subject to change up to version 1.0.
List of endpoints implemented:
- Dataset - All methods
- Table - All methods
- Tabledata - All methods
- Job - All methods
- Model - All methods (not tested)
- Project (not tested)
- Routine - All methods (not tested)