Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions grid_render/src/bigquery/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub start_index: Option<String>,
pub max_results: Option<usize>,
// formatOptions: DataFormatOptions;
}

#[derive(Debug)]
Expand Down Expand Up @@ -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());
}
Expand Down
3 changes: 3 additions & 0 deletions grid_render/src/custom_elements/bq_query_custom_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down