yoshidan / google-cloud-rust

Google Cloud Client Libraries for Rust.
MIT License
251 stars 98 forks source link

How to set Location for google-cloud-bigquery #269

Open crbl1122 opened 6 months ago

crbl1122 commented 6 months ago

How can I set location in the BigQuery client?

The client is looking by default for the dataset in Region US while it is located in a different region.

use google_cloud_bigquery::client::{ClientConfig, Client};

#[tokio::main]
async fn main() {
    let (config, project_id) = ClientConfig::new_with_auth().await.unwrap();
    let client = Client::new(config).await.unwrap();
    run(&client, project_id.as_deref().unwrap_or_default()).await;

}

The error:

thread 'main' panicked at src/main.rs:17:67:
called `Result::unwrap()` on an `Err` value: JobHttp(Response(ErrorResponse { code: 404, errors: Some([ErrorResponseItem { message: "Not found: Dataset PROJECT_ID:DATASET_ID **was not found in location US**", reason: "notFound" }]), message: "Not found: Dataset PROJECT_ID:DATASET_ID was not found in location US" }))
yoshidan commented 1 month ago

Location can be specified when creating a dataset.

https://github.com/yoshidan/google-cloud-rust/blob/497f2d200e2a3a1217dd1c3e9a6515efe77c762f/bigquery/src/http/dataset/mod.rs#L205

The dataset is globally unique. So the location does not need to be specified when searching. if the dataset cannot be found, you will get the error you have described.

Please check if the dataset you specified is available in one of the regions.