Skip to content

Commit

Permalink
fix(presto-driver): optimize testConnection() to issue simple select …
Browse files Browse the repository at this point in the history
…1 test instead of heavy show catalogs
  • Loading branch information
KSDaemon committed Jan 17, 2025
1 parent 6d75c60 commit 0949d69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/cubejs-prestodb-driver/src/PrestoDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<Promise<any[]>> this.queryPromised(query, false))
.then(catalogs => {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0949d69

Please sign in to comment.