google-cloud-rust icon indicating copy to clipboard operation
google-cloud-rust copied to clipboard

How to set Location for google-cloud-bigquery

Open crbl1122 opened this issue 1 year ago • 1 comments

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" }))

crbl1122 avatar May 20 '24 13:05 crbl1122

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.

yoshidan avatar Oct 06 '24 03:10 yoshidan