bigquery fixes 👍🏼

This commit is contained in:
dal 2025-09-17 08:17:01 -06:00
parent 85a8c96056
commit e9f2ca5bd6
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
2 changed files with 14 additions and 3 deletions

View File

@ -51,6 +51,7 @@ describe('BigQueryAdapter', () => {
private_key: 'test-key', private_key: 'test-key',
client_email: 'test@test.iam.gserviceaccount.com', client_email: 'test@test.iam.gserviceaccount.com',
}, },
location: 'US',
}); });
}); });
@ -67,6 +68,7 @@ describe('BigQueryAdapter', () => {
expect(BigQuery).toHaveBeenCalledWith({ expect(BigQuery).toHaveBeenCalledWith({
projectId: 'test-project', projectId: 'test-project',
keyFilename: '/path/to/key.json', keyFilename: '/path/to/key.json',
location: 'US',
}); });
}); });
@ -103,6 +105,7 @@ describe('BigQueryAdapter', () => {
expect.objectContaining({ expect.objectContaining({
projectId: 'test-project', projectId: 'test-project',
credentials: serviceAccountObject, credentials: serviceAccountObject,
location: 'US',
}) })
); );
}); });
@ -131,6 +134,7 @@ describe('BigQueryAdapter', () => {
expect(BigQuery).toHaveBeenCalledWith( expect(BigQuery).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
projectId: 'test-project', projectId: 'test-project',
location: 'US',
}) })
); );
}); });
@ -149,6 +153,7 @@ describe('BigQueryAdapter', () => {
expect(BigQuery).toHaveBeenCalledWith( expect(BigQuery).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
projectId: 'test-project', projectId: 'test-project',
location: 'us-central1',
}) })
); );
}); });

View File

@ -49,9 +49,8 @@ export class BigQueryAdapter extends BaseAdapter {
options.keyFilename = bigqueryCredentials.key_file_path; options.keyFilename = bigqueryCredentials.key_file_path;
} }
if (bigqueryCredentials.location) { // Set location - default to US if not specified
options.location = bigqueryCredentials.location; options.location = bigqueryCredentials.location || 'US';
}
this.client = new BigQuery(options); this.client = new BigQuery(options);
this.credentials = credentials; this.credentials = credentials;
@ -79,6 +78,13 @@ export class BigQueryAdapter extends BaseAdapter {
// Fix SQL to ensure proper escaping of identifiers with special characters // Fix SQL to ensure proper escaping of identifiers with special characters
const fixedSql = fixBigQueryTableReferences(sql); const fixedSql = fixBigQueryTableReferences(sql);
// Debug logging to verify the fix is applied
if (sql !== fixedSql) {
console.log('[BigQuery] SQL fixed for special characters:');
console.log(' Original:', sql);
console.log(' Fixed: ', fixedSql);
}
const options: Query = { const options: Query = {
query: fixedSql, query: fixedSql,
useLegacySql: false, useLegacySql: false,