Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

Commit 9e5bae2

Browse files
authored
feat: add support for accessing jobs cross-project (#1083)
* feat: add support accessing jobs cross-project * fix test
1 parent 6cbe7da commit 9e5bae2

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/bigquery.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export type JobRequest<J> = J & {
6666
jobId?: string;
6767
jobPrefix?: string;
6868
location?: string;
69+
projectId?: string;
6970
};
7071

7172
export type PagedRequest<P> = P & {

src/job.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export type QueryResultsOptions = {
124124
class Job extends Operation {
125125
bigQuery: BigQuery;
126126
location?: string;
127+
projectId?: string;
127128
getQueryResultsStream(
128129
options?: QueryResultsOptions
129130
): ResourceStream<RowMetadata> {
@@ -344,6 +345,10 @@ class Job extends Operation {
344345
this.location = options.location;
345346
}
346347

348+
if (options?.projectId) {
349+
this.projectId = options.projectId;
350+
}
351+
347352
/**
348353
* Get the results of a job as a readable object stream.
349354
*

test/job.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ describe('BigQuery/Job', () => {
147147
assert.strictEqual(job.location, options.location);
148148
});
149149

150+
it('should accept a projectId option', () => {
151+
const options = {projectId: 'cool-project'};
152+
const job = new Job(BIGQUERY, JOB_ID, options);
153+
154+
assert.strictEqual(job.projectId, options.projectId);
155+
});
156+
150157
it('should send the location via getMetadata', () => {
151158
const job = new Job(BIGQUERY, JOB_ID, {location: LOCATION});
152159
const calledWith = job.calledWith_[0];

0 commit comments

Comments
 (0)