Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit b1110cc

Browse files
authored
Merge pull request #174 from doitintl/issue-172
Fixes #172 Allow specifying processing location
2 parents 18f6fee + db20d03 commit b1110cc

File tree

7 files changed

+112
-8
lines changed

7 files changed

+112
-8
lines changed

dist/module.js

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58479,6 +58479,7 @@ function () {
5847958479
target.format = target.format || "time_series";
5848058480
target.orderByCol = target.orderByCol || "1";
5848158481
target.orderBySort = target.orderBySort || "1";
58482+
target.location = target.location || "US";
5848258483
target.timeColumn = target.timeColumn || "-- time --";
5848358484
target.timeColumnType = target.timeColumnType || "TIMESTAMP";
5848458485
target.metricColumn = target.metricColumn || "none";
@@ -59908,6 +59909,7 @@ function () {
5990859909
/*return*/
5990959910
, this.backendSrv.datasourceRequest({
5991059911
data: {
59912+
location: this.queryModel.target.location,
5991159913
query: query,
5991259914
useLegacySql: false,
5991359915
useQueryCache: true
@@ -59948,7 +59950,7 @@ function () {
5994859950
case 0:
5994959951
sleepTimeMs = 100;
5995059952
console.log("New job id: ", jobId);
59951-
path = "v2/projects/" + this.runInProject + "/queries/" + jobId;
59953+
path = "v2/projects/" + this.runInProject + "/queries/" + jobId + "?location=" + this.queryModel.target.location;
5995259954
_a.label = 1;
5995359955

5995459956
case 1:
@@ -59993,7 +59995,7 @@ function () {
5999359995
if (!queryResults.data.pageToken) return [3
5999459996
/*break*/
5999559997
, 2];
59996-
path = "v2/projects/" + this.runInProject + "/queries/" + jobId + "?pageToken=" + queryResults.data.pageToken;
59998+
path = "v2/projects/" + this.runInProject + "/queries/" + jobId + "?pageToken=" + queryResults.data.pageToken + "&location=" + this.queryModel.target.location;
5999759999
return [4
5999860000
/*yield*/
5999960001
, this.doRequest("" + this.baseUrl + path, requestId)];
@@ -60311,6 +60313,58 @@ function (_super) {
6031160313
text: "DESC",
6031260314
value: "2"
6031360315
}];
60316+
_this.locations = [{
60317+
text: "United States (US)",
60318+
value: "US"
60319+
}, {
60320+
text: "European Union (EU)",
60321+
value: "EU"
60322+
}, {
60323+
text: "Los Angeles (us-west2)",
60324+
value: "us-west2"
60325+
}, {
60326+
text: "Montréal (northamerica-northeast1)",
60327+
value: "northamerica-northeast1"
60328+
}, {
60329+
text: "Northern Virginia (us-east4)",
60330+
value: "us-east4"
60331+
}, {
60332+
text: "São Paulo (southamerica-east1)",
60333+
value: "southamerica-east1"
60334+
}, {
60335+
text: "Finland (europe-north1)",
60336+
value: "europe-north1"
60337+
}, {
60338+
text: "London (europe-west2)",
60339+
value: "europe-west2"
60340+
}, {
60341+
text: "Frankfurt (europe-west3)",
60342+
value: "europe-west3"
60343+
}, {
60344+
text: "Zürich (europe-west6)",
60345+
value: "europe-west6"
60346+
}, {
60347+
text: "Hong Kong (asia-east2)",
60348+
value: "asia-east2"
60349+
}, {
60350+
text: "Mumbai (asia-south1)",
60351+
value: "asia-south1"
60352+
}, {
60353+
text: "Osaka (asia-northeast2)",
60354+
value: "asia-northeast2"
60355+
}, {
60356+
text: "Taiwan (asia-east1)",
60357+
value: "asia-east1"
60358+
}, {
60359+
text: "Tokyo (asia-northeast1)",
60360+
value: "asia-northeast1"
60361+
}, {
60362+
text: "Singapore (asia-southeast1)",
60363+
value: "asia-southeast1"
60364+
}, {
60365+
text: "Sydney (australia-southeast1)",
60366+
value: "australia-southeast1"
60367+
}];
6031460368

6031560369
if (!_this.target.rawSql) {
6031660370
// special handling when in table panel

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/partials/query.editor.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,22 @@
151151
ng-change="ctrl.refresh()"></select>
152152
</div>
153153
</div>
154-
154+
<div>
155155
<gf-form-switch class="gf-form"
156156
label="Convert time filters to UTC"
157157
label-class="query-keyword"
158158
checked="ctrl.target.convertToUTC"
159159
</gf-form-switch>
160+
</div>
161+
<div class="gf-form">
162+
<label class="gf-form-label query-keyword">Processing Location</label>
163+
<div class="gf-form-select-wrapper">
164+
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.location"
165+
ng-options="f.value as f.text for f in ctrl.locations"
166+
ng-change="ctrl.refresh()"></select>
167+
</div>
168+
</div>
169+
160170
<div class="gf-form">
161171
<label class="gf-form-label query-keyword pointer"
162172
ng-click="ctrl.toggleEditorMode()"

src/bigquery_query.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export default class BigQueryQuery {
106106
target.format = target.format || "time_series";
107107
target.orderByCol = target.orderByCol || "1";
108108
target.orderBySort = target.orderBySort || "1";
109+
target.location = target.location || "US";
109110
target.timeColumn = target.timeColumn || "-- time --";
110111
target.timeColumnType = target.timeColumnType || "TIMESTAMP";
111112
target.metricColumn = target.metricColumn || "none";

src/datasource.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ export class BigQueryDatasource {
475475
return this.backendSrv
476476
.datasourceRequest({
477477
data: {
478+
location: this.queryModel.target.location,
478479
query,
479480
useLegacySql: false,
480481
useQueryCache: true
@@ -506,7 +507,11 @@ export class BigQueryDatasource {
506507
private async _waitForJobComplete(queryResults, requestId, jobId) {
507508
let sleepTimeMs = 100;
508509
console.log("New job id: ", jobId);
509-
const path = `v2/projects/${this.runInProject}/queries/` + jobId;
510+
const path =
511+
`v2/projects/${this.runInProject}/queries/` +
512+
jobId +
513+
"?location=" +
514+
this.queryModel.target.location;
510515
while (!queryResults.data.jobComplete) {
511516
await sleep(sleepTimeMs);
512517
sleepTimeMs *= 2;
@@ -523,7 +528,9 @@ export class BigQueryDatasource {
523528
`v2/projects/${this.runInProject}/queries/` +
524529
jobId +
525530
"?pageToken=" +
526-
queryResults.data.pageToken;
531+
queryResults.data.pageToken +
532+
"&location=" +
533+
this.queryModel.target.location;
527534
queryResults = await this.doRequest(`${this.baseUrl}${path}`, requestId);
528535
if (queryResults.length === 0) {
529536
return rows;

src/partials/query.editor.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,22 @@
151151
ng-change="ctrl.refresh()"></select>
152152
</div>
153153
</div>
154-
154+
<div>
155155
<gf-form-switch class="gf-form"
156156
label="Convert time filters to UTC"
157157
label-class="query-keyword"
158158
checked="ctrl.target.convertToUTC"
159159
</gf-form-switch>
160+
</div>
161+
<div class="gf-form">
162+
<label class="gf-form-label query-keyword">Processing Location</label>
163+
<div class="gf-form-select-wrapper">
164+
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.location"
165+
ng-options="f.value as f.text for f in ctrl.locations"
166+
ng-change="ctrl.refresh()"></select>
167+
</div>
168+
</div>
169+
160170
<div class="gf-form">
161171
<label class="gf-form-label query-keyword pointer"
162172
ng-click="ctrl.toggleEditorMode()"

src/query_ctrl.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class BigQueryQueryCtrl extends QueryCtrl {
2626
public queryModel: BigQueryQuery;
2727
public lastQueryMeta: QueryMeta;
2828
public lastQueryError: string;
29+
public locations:any[];
2930
public showHelp: boolean;
3031
public projectSegment: any;
3132
public datasetSegment: any;
@@ -68,7 +69,28 @@ export class BigQueryQueryCtrl extends QueryCtrl {
6869
{ text: "ASC", value: "1" },
6970
{ text: "DESC", value: "2" }
7071
];
71-
72+
this.locations = [
73+
{ text: "United States (US)", value: "US" },
74+
{ text: "European Union (EU)", value: "EU" },
75+
{ text: "Los Angeles (us-west2)", value: "us-west2" },
76+
{
77+
text: "Montréal (northamerica-northeast1)",
78+
value: "northamerica-northeast1"
79+
},
80+
{ text: "Northern Virginia (us-east4)", value: "us-east4" },
81+
{ text: "São Paulo (southamerica-east1)", value: "southamerica-east1" },
82+
{ text: "Finland (europe-north1)", value: "europe-north1" },
83+
{ text: "London (europe-west2)", value: "europe-west2" },
84+
{ text: "Frankfurt (europe-west3)", value: "europe-west3" },
85+
{ text: "Zürich (europe-west6)", value: "europe-west6" },
86+
{ text: "Hong Kong (asia-east2)", value: "asia-east2" },
87+
{ text: "Mumbai (asia-south1)", value: "asia-south1" },
88+
{ text: "Osaka (asia-northeast2)", value: "asia-northeast2" },
89+
{ text: "Taiwan (asia-east1)", value: "asia-east1" },
90+
{ text: "Tokyo (asia-northeast1)", value: "asia-northeast1" },
91+
{ text: "Singapore (asia-southeast1)", value: "asia-southeast1" },
92+
{ text: "Sydney (australia-southeast1)", value: "australia-southeast1" }
93+
];
7294
if (!this.target.rawSql) {
7395
// special handling when in table panel
7496
if (this.panelCtrl.panel.type === "table") {

0 commit comments

Comments
 (0)