Skip to content

Commit aa36e92

Browse files
committed
adds support for non US dataset locations
1 parent 1591b3b commit aa36e92

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

connection.schema.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
"GCloud CLI"
2323
],
2424
"default": "SERVICE_ACCOUNT"
25+
},
26+
"location": {
27+
"title": "Location",
28+
"type": "string",
29+
"minLength": 1,
30+
"default": "us"
2531
}
2632
},
2733
"dependencies": {
@@ -41,7 +47,7 @@
4147
}
4248
},
4349
"required": [
44-
"authenticator", "keyfile"
50+
"authenticator", "keyfile", "location"
4551
]
4652
},
4753
{
@@ -63,7 +69,7 @@
6369
}
6470
},
6571
"required": [
66-
"authenticator", "token", "projectId"
72+
"authenticator", "token", "projectId", "location"
6773
]
6874
},
6975
{
@@ -80,7 +86,7 @@
8086
}
8187
},
8288
"required": [
83-
"authenticator", "projectId"
89+
"authenticator", "projectId", "location"
8490
]
8591
}
8692
]

src/ls/driver.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ export default class BigQueryDriver extends AbstractDriver<DriverLib, DriverOpti
2929

3030
public async open() {
3131
const getCredentials = () => {
32+
33+
3234
const authentication_method = this.credentials.authenticator
3335
if (authentication_method === 'CLI') {
3436
return {
35-
projectId: this.credentials.projectId
37+
projectId: this.credentials.projectId,
38+
location: this.credentials.location
3639
};
3740
} else if (authentication_method === 'OAUTH') {
3841
// currently causing error
@@ -43,12 +46,14 @@ export default class BigQueryDriver extends AbstractDriver<DriverLib, DriverOpti
4346
return {
4447
// is this a legit way to handle this typescript error
4548
authClient: oauth as JSONClient,
46-
projectId: this.credentials.projectId
49+
projectId: this.credentials.projectId,
50+
location: this.credentials.location
4751
};
4852
} else {
4953
console.log('keyfile', this.credentials.keyfile)
5054
return {
51-
keyFilename: this.credentials.keyfile
55+
keyFilename: this.credentials.keyfile,
56+
location: this.credentials.location
5257
}
5358
};
5459
}
@@ -57,6 +62,7 @@ export default class BigQueryDriver extends AbstractDriver<DriverLib, DriverOpti
5762

5863
this.connection = new Promise((resolve, reject) => {
5964
try {
65+
console.log('connOptions', connOptions)
6066
const bigquery = new BigQuery({ ...connOptions, maxRetries: 10 });
6167
resolve(bigquery);
6268
} catch (error) {
@@ -91,6 +97,7 @@ export default class BigQueryDriver extends AbstractDriver<DriverLib, DriverOpti
9197
const options = {
9298
// typescript complains if this is not an array
9399
query: [query],
100+
location: this.credentials.location,
94101
};
95102
const resultsAgg: NSDatabase.IResult[] = [];
96103

ui.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
},
1717
"token": {
1818
"ui:widget": "password"
19+
},
20+
"location": {
21+
"ui:help": "Default `us`. Each connection can access one location. Full location list: https://cloud.google.com/bigquery/docs/locations"
1922
}
2023

2124
}

0 commit comments

Comments
 (0)