From 0949d692c2848aad916bcba42281986bb8129002 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Fri, 17 Jan 2025 16:28:58 +0200 Subject: [PATCH] fix(presto-driver): optimize testConnection() to issue simple select 1 test instead of heavy show catalogs --- packages/cubejs-prestodb-driver/src/PrestoDriver.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cubejs-prestodb-driver/src/PrestoDriver.ts b/packages/cubejs-prestodb-driver/src/PrestoDriver.ts index 8232349ddbd3e..877225e5a6345 100644 --- a/packages/cubejs-prestodb-driver/src/PrestoDriver.ts +++ b/packages/cubejs-prestodb-driver/src/PrestoDriver.ts @@ -103,7 +103,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface { } public testConnection() { - const query = SqlString.format('show catalogs like ?', [`%${this.catalog}%`]); + const query = ('SELECT 1'); return (> this.queryPromised(query, false)) .then(catalogs => { @@ -230,7 +230,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface { if (!this.config.exportBucket) { throw new Error('Export bucket is not configured.'); } - + if (!SUPPORTED_BUCKET_TYPES.includes(this.config.bucketType as string)) { throw new Error(`Unsupported export bucket type: ${ this.config.bucketType @@ -240,7 +240,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface { const types = options.query ? await this.unloadWithSql(tableName, options.query.sql, options.query.params) : await this.unloadWithTable(tableName); - + const csvFile = await this.getCsvFiles(tableName); return { @@ -287,7 +287,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface { const { bucketType, exportBucket } = this.config; const types = await this.queryColumnTypes(params.typeSql, params.typeParams); - + const { schema, tableName } = this.splitTableFullName(params.tableFullName); const tableWithCatalogAndSchema = `${this.config.catalog}.${schema}.${tableName}`; const protocol = bucketType === 'gcs' ? 'gs' : bucketType;