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

fix(Google BigQuery Node): Location default to jobReference #7354

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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 });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

location is not actually using the const location from above.

} catch (error) {
if (this.continueOnFail()) {
Expand Down
Original file line number Diff line number Diff line change
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
Loading