@@ -102,15 +102,18 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
102102 this . client = new presto . Client ( this . config ) ;
103103 }
104104
105- public testConnection ( ) {
106- const query = SqlString . format ( 'show catalogs like ?' , [ `%${ this . catalog } %` ] ) ;
107-
108- return ( < Promise < any [ ] > > this . queryPromised ( query , false ) )
109- . then ( catalogs => {
110- if ( catalogs . length === 0 ) {
111- throw new Error ( `Catalog not found '${ this . catalog } '` ) ;
105+ public async testConnection ( ) : Promise < void > {
106+ return new Promise ( ( resolve , reject ) => {
107+ // Get node list of presto cluster and return it.
108+ // @see https://prestodb.io/docs/current/rest/node.html
109+ this . client . nodes ( null , ( error : any , _result : any [ ] ) => {
110+ if ( error ) {
111+ reject ( error ) ;
112+ } else {
113+ resolve ( ) ;
112114 }
113115 } ) ;
116+ } ) ;
114117 }
115118
116119 public query ( query : string , values : unknown [ ] ) : Promise < any [ ] > {
@@ -230,7 +233,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
230233 if ( ! this . config . exportBucket ) {
231234 throw new Error ( 'Export bucket is not configured.' ) ;
232235 }
233-
236+
234237 if ( ! SUPPORTED_BUCKET_TYPES . includes ( this . config . bucketType as string ) ) {
235238 throw new Error ( `Unsupported export bucket type: ${
236239 this . config . bucketType
@@ -240,7 +243,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
240243 const types = options . query
241244 ? await this . unloadWithSql ( tableName , options . query . sql , options . query . params )
242245 : await this . unloadWithTable ( tableName ) ;
243-
246+
244247 const csvFile = await this . getCsvFiles ( tableName ) ;
245248
246249 return {
@@ -287,7 +290,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
287290
288291 const { bucketType, exportBucket } = this . config ;
289292 const types = await this . queryColumnTypes ( params . typeSql , params . typeParams ) ;
290-
293+
291294 const { schema, tableName } = this . splitTableFullName ( params . tableFullName ) ;
292295 const tableWithCatalogAndSchema = `${ this . config . catalog } .${ schema } .${ tableName } ` ;
293296 const protocol = bucketType === 'gcs' ? 'gs' : bucketType ;
0 commit comments