diff --git a/packages/cubejs-backend-shared/src/env.ts b/packages/cubejs-backend-shared/src/env.ts index a263fc36c217b..7e53dab8c87b0 100644 --- a/packages/cubejs-backend-shared/src/env.ts +++ b/packages/cubejs-backend-shared/src/env.ts @@ -479,6 +479,17 @@ const variables: Record any> = { return val; }, + /** + * Flag to disable driver's test connection probes + */ + dbDisableTestConnection: ({ + dataSource + }: { + dataSource: string, + }) => ( + !!process.env[keyByDataSource('CUBEJS_DB_DISABLE_TEST_CONNECTION', dataSource)] + ), + /** * Database max pool size. */ @@ -500,7 +511,7 @@ const variables: Record any> = { ), /** - * Max polling interval. Currenly used in BigQuery and Databricks. + * Max polling interval. Currently used in BigQuery and Databricks. * TODO: clarify this env. */ dbPollMaxInterval: ({ @@ -514,7 +525,7 @@ const variables: Record any> = { }, /** - * Polling timeout. Currenly used in BigQuery, Dremio and Athena. + * Polling timeout. Currently used in BigQuery, Dremio and Athena. * TODO: clarify this env. */ dbPollTimeout: ({ @@ -532,7 +543,7 @@ const variables: Record any> = { }, /** - * Query timeout. Currenly used in BigQuery, Dremio, Postgres, Snowflake + * Query timeout. Currently used in BigQuery, Dremio, Postgres, Snowflake * and Athena drivers and the orchestrator (queues, pre-aggs). For the * orchestrator this variable did not split by the datasource. * diff --git a/packages/cubejs-base-driver/src/BaseDriver.ts b/packages/cubejs-base-driver/src/BaseDriver.ts index cf4ff4793f590..aa9fac1228270 100644 --- a/packages/cubejs-base-driver/src/BaseDriver.ts +++ b/packages/cubejs-base-driver/src/BaseDriver.ts @@ -171,10 +171,12 @@ const DbTypeValueMatcher: Record boolean)> = { * Base driver class. */ export abstract class BaseDriver implements DriverInterface { - private testConnectionTimeoutValue = 10000; + private readonly testConnectionTimeoutValue: number = 10000; protected logger: any; + protected isTestConnectionDisabledFlag: boolean = false; + /** * Class constructor. */ @@ -184,8 +186,14 @@ export abstract class BaseDriver implements DriverInterface { * request before determining it as not valid. Default - 10000 ms. */ testConnectionTimeout?: number, + + /** + * Flag for serverless DWHs to omit test connection probes. + */ + isTestConnectionDisabled?: boolean, } = {}) { this.testConnectionTimeoutValue = _options.testConnectionTimeout || 10000; + this.isTestConnectionDisabledFlag = _options.isTestConnectionDisabled || false; } protected informationSchemaQuery() { @@ -680,6 +688,10 @@ export abstract class BaseDriver implements DriverInterface { query.query = `SELECT * FROM (${query.query}) AS t LIMIT ${query.limit}`; } + public isTestConnectionDisabled(): boolean { + return !!this.isTestConnectionDisabledFlag; + } + /** * Returns an array of signed AWS S3 URLs of the unloaded csv files. */