Skip to content
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
6 changes: 4 additions & 2 deletions packages/cubejs-firebolt-driver/src/FireboltDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type FireboltDriverConfiguration = {
readOnly?: boolean;
apiEndpoint?: string;
connection: ConnectionOptions;
requestTimeout: number;
};

const FireboltTypeToGeneric: Record<string, string> = {
Expand Down Expand Up @@ -91,6 +92,7 @@ export class FireboltDriver extends BaseDriver implements DriverInterface {

this.config = {
readOnly: true,
requestTimeout: getEnv('dbQueryTimeout') * 1000,
apiEndpoint:
getEnv('fireboltApiEndpoint', { dataSource }) || 'api.app.firebolt.io',
...config,
Expand Down Expand Up @@ -225,7 +227,7 @@ export class FireboltDriver extends BaseDriver implements DriverInterface {
const connection = await this.getConnection();

const statement = await connection.execute(query, {
settings: { output_format: OutputFormat.JSON },
settings: { output_format: OutputFormat.JSON, statement_timeout: this.config.requestTimeout },
parameters,
response: { hydrateRow: this.hydrateRow }
});
Expand Down Expand Up @@ -275,7 +277,7 @@ export class FireboltDriver extends BaseDriver implements DriverInterface {
const connection = await this.getConnection();

const statement = await connection.execute(query, {
settings: { output_format: OutputFormat.JSON },
settings: { output_format: OutputFormat.JSON, statement_timeout: this.config.requestTimeout },
parameters,
response: { hydrateRow: this.hydrateRow }
});
Expand Down
19 changes: 19 additions & 0 deletions packages/cubejs-firebolt-driver/test/FireboltDriver.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DriverTests } from '@cubejs-backend/testing-shared';

import { FireboltDriver } from '../src';
import { getEnv } from '@cubejs-backend/shared';

describe('FireboltDriver', () => {
let tests: DriverTests;
Expand All @@ -22,4 +23,22 @@ describe('FireboltDriver', () => {
test('stream', async () => {
await tests.testStream();
});

test('query should fail on timeout', async () => {
const slowQuery = 'SELECT checksum(*) FROM GENERATE_SERIES(1, 1000000000000)';
// Set query timeout to 2 seconds
process.env.CUBEJS_DB_QUERY_TIMEOUT = '2';
const driver = new FireboltDriver({});

let timedOut = false;
try {
await driver.query(slowQuery);
} catch (e) {
if (String(e).toLowerCase().includes('timeout expired (2000 ms)')) {
timedOut = true;
}
}

expect(timedOut).toBe(true);
}, 10000);
});
Loading