From 9e650bd4ff82ad02de2bb65d38de27d92d44b490 Mon Sep 17 00:00:00 2001 From: robsoncdtoledo Date: Mon, 23 Mar 2026 11:43:27 -0300 Subject: [PATCH 1/2] fix: include location parameter in getQueryResults API request --- grid_render/src/bigquery/jobs.rs | 13 +++++++++++-- .../src/custom_elements/bq_query_custom_element.rs | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/grid_render/src/bigquery/jobs.rs b/grid_render/src/bigquery/jobs.rs index be9c041..c838c7a 100644 --- a/grid_render/src/bigquery/jobs.rs +++ b/grid_render/src/bigquery/jobs.rs @@ -393,9 +393,12 @@ impl Job { pub struct GetQueryResultsRequest { pub project_id: String, pub job_id: String, + /// The BigQuery region where the job was created (e.g. "southamerica-east1", "US", "EU"). + /// Required for jobs outside the default US region — omitting it causes a 404 from the API. + /// See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults + pub location: Option, pub start_index: Option, pub max_results: Option, - // formatOptions: DataFormatOptions; } #[derive(Debug)] @@ -630,12 +633,18 @@ impl Jobs { request.project_id, request.job_id ); - // if (request.location) { url.searchParams.append("location", request.location); } if request.max_results.is_some() { url = format!("{}?maxResults={}", url, request.max_results.unwrap()); } else { url = format!("{}?maxResults=50", url); } + // Append the `location` query parameter so the API can route the request to the correct + // region. Without this, jobs created outside the default US region return a 404. + if let Some(location) = &request.location { + if !location.is_empty() { + url = format!("{}&location={}", url, location); + } + } if request.start_index.is_some() { url = format!("{}&startIndex={}", url, request.start_index.unwrap()); } diff --git a/grid_render/src/custom_elements/bq_query_custom_element.rs b/grid_render/src/custom_elements/bq_query_custom_element.rs index de9401b..7569e45 100644 --- a/grid_render/src/custom_elements/bq_query_custom_element.rs +++ b/grid_render/src/custom_elements/bq_query_custom_element.rs @@ -158,6 +158,9 @@ impl BigqueryQueryCustomElement { GetQueryResultsRequest { project_id: self.project_id.clone(), job_id: self.job_id.clone(), + // Pass the job's location so the getQueryResults request includes the `location` + // query parameter. Jobs outside the default US region return a 404 without it. + location: Some(self.location.clone()), start_index: Some(self.page_start_index.clone().to_string()), max_results: Some(self.page_size), } From 3614fe9a6da54f526bcfd8670b9a616929c0f5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A3o?= Date: Thu, 26 Mar 2026 12:11:21 +0000 Subject: [PATCH 2/2] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d19273..862d703 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-bigquery", "displayName": "Bigquery Data View", "description": "Google BigQuery extension for Visual Studio Code. List datasets and tables, view table contents, and run queries.", - "version": "0.5.0", + "version": "0.5.1", "publisher": "bstruct", "icon": "logo.png", "repository": {