Skip to content

Commit

Permalink
fix(Google BigQuery Node): Location default to jobReference (#7354)
Browse files Browse the repository at this point in the history
Github issue / Community forum post (link here to close automatically):
  • Loading branch information
michael-radency authored and netroy committed Oct 9, 2023
1 parent 73a98cb commit 489a12d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -7,7 +7,7 @@ import type {

import { NodeOperationError, sleep } from 'n8n-workflow';
import { getResolvables, updateDisplayOptions } from '@utils/utilities';
import type { JobInsertResponse } from '../../helpers/interfaces';
import type { ResponseWithJobReference } from '../../helpers/interfaces';

import { prepareOutput } from '../../helpers/utils';
import { googleApiRequest } from '../../transport';
Expand Down Expand Up @@ -205,7 +205,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
body.useLegacySql = false;
}

const response: JobInsertResponse = await googleApiRequest.call(
const response: ResponseWithJobReference = await googleApiRequest.call(
this,
'POST',
`/v2/projects/${projectId}/jobs`,
Expand All @@ -225,9 +225,10 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa

const jobId = response?.jobReference?.jobId;
const raw = rawOutput || (options.dryRun as boolean) || false;
const location = options.location || response.jobReference.location;

if (response.status?.state === 'DONE') {
const qs = options.location ? { location: options.location } : {};
const qs = { location };

const queryResponse: IDataObject = await googleApiRequest.call(
this,
Expand All @@ -239,7 +240,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa

returnData.push(...prepareOutput.call(this, queryResponse, i, raw, includeSchema));
} else {
jobs.push({ jobId, projectId, i, raw, includeSchema, location: options.location });
jobs.push({ jobId, projectId, i, raw, includeSchema, location });
}
} catch (error) {
if (this.continueOnFail()) {
Expand Down
Expand Up @@ -21,7 +21,7 @@ export type JobReference = {
location: string;
};

export type JobInsertResponse = {
export type ResponseWithJobReference = {
kind: string;
id: string;
jobReference: JobReference;
Expand Down

0 comments on commit 489a12d

Please sign in to comment.