Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for TPC Universes #1333

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: lint issues
  • Loading branch information
alvarowolfx committed Feb 8, 2024
commit 0d885645f5d23000697beadfcc201b5fca5067a7
12 changes: 6 additions & 6 deletions src/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,33 +319,33 @@
location?: string;
private _universeDomain: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use:

Suggested change
private _universeDomain: string;
#universeDomain: string;

To make it truly private.


createQueryStream(options?: Query | string): ResourceStream<RowMetadata> {

Check warning on line 322 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
// placeholder body, overwritten in constructor
return new ResourceStream<RowMetadata>({}, () => {});
}

getDatasetsStream(options?: GetDatasetsOptions): ResourceStream<Dataset> {

Check warning on line 327 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
// placeholder body, overwritten in constructor
return new ResourceStream<Dataset>({}, () => {});
}

getJobsStream(options?: GetJobsOptions): ResourceStream<Job> {

Check warning on line 332 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
// placeholder body, overwritten in constructor
return new ResourceStream<Job>({}, () => {});
}

constructor(options: BigQueryOptions = {}) {
let universeDomain = "googleapis.com";
const servicePath = "bigquery";
let universeDomain = 'googleapis.com';
const servicePath = 'bigquery';

if (options.universeDomain) {
universeDomain = BigQuery.sanitizeDomain(options.universeDomain);
}

const EMULATOR_HOST = process.env.BIGQUERY_EMULATOR_HOST;

let apiEndpoint = `https://${servicePath}.${universeDomain}`;
let apiEndpoint = `https://${servicePath}.${universeDomain}`;
alvarowolfx marked this conversation as resolved.
Show resolved Hide resolved

if (typeof EMULATOR_HOST === 'string') {
apiEndpoint = BigQuery.sanitizeEndpoint(EMULATOR_HOST);
}
Expand Down Expand Up @@ -488,7 +488,7 @@
});
}

get universeDomain(){
get universeDomain() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: In the future we may want to check via Auth’s universe domain getter; which is async.

return this._universeDomain;
}

Expand All @@ -499,7 +499,7 @@
return this.sanitizeDomain(url);
}

private static sanitizeDomain(url: string) {
private static sanitizeDomain(url: string) {
return url.replace(/\/+$/, ''); // Remove trailing slashes
}

Expand Down
12 changes: 9 additions & 3 deletions test/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,15 @@ describe('BigQuery', () => {
universeDomain: universeDomain,
});
const calledWith = bq.calledWith_[0];
assert.strictEqual(calledWith.baseUrl, `https://bigquery.apis-tpclp.goog/bigquery/v2`);
assert.strictEqual(calledWith.apiEndpoint, `https://bigquery.apis-tpclp.goog`);
})
assert.strictEqual(
calledWith.baseUrl,
'https://bigquery.apis-tpclp.goog/bigquery/v2'
);
assert.strictEqual(
calledWith.apiEndpoint,
'https://bigquery.apis-tpclp.goog'
);
});

it('should capture any user specified location', () => {
const bq = new BigQuery({
Expand Down