File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed
cubejs-prestodb-driver/src
cubejs-schema-compiler/src/adapter Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,11 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
6060 return 2 ;
6161 }
6262
63- private config : PrestoDriverConfiguration ;
63+ protected readonly config : PrestoDriverConfiguration ;
6464
65- private catalog : string | undefined ;
65+ protected readonly catalog : string | undefined ;
6666
67- private client : any ;
67+ protected client : any ;
6868
6969 /**
7070 * Class constructor.
Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ export * from './CubeStoreQuery';
1616export * from './MysqlQuery' ;
1717export * from './PostgresQuery' ;
1818export * from './MssqlQuery' ;
19+ export * from './PrestodbQuery' ;
1920
2021// Candidates to move from this package to drivers packages
21- // export * from './PrestodbQuery';
2222// export * from './RedshiftQuery';
2323// export * from './SnowflakeQuery';
2424// export * from './SqliteQuery';
Original file line number Diff line number Diff line change 2929 "@cubejs-backend/prestodb-driver" : " 1.3.18" ,
3030 "@cubejs-backend/schema-compiler" : " 1.3.18" ,
3131 "@cubejs-backend/shared" : " 1.3.18" ,
32+ "node-fetch" : " ^2.6.1" ,
3233 "presto-client" : " ^0.12.2" ,
3334 "sqlstring" : " ^2.3.1"
3435 },
Original file line number Diff line number Diff line change 1+ import fetch from 'node-fetch' ;
12import { PrestoDriver } from '@cubejs-backend/prestodb-driver' ;
2- import { PrestodbQuery } from '@cubejs-backend/schema-compiler/dist/src/adapter/PrestodbQuery ' ;
3+ import { PrestodbQuery } from '@cubejs-backend/schema-compiler' ;
34
45export class TrinoDriver extends PrestoDriver {
56 public constructor ( options : any ) {
@@ -9,4 +10,23 @@ export class TrinoDriver extends PrestoDriver {
910 public static dialectClass ( ) {
1011 return PrestodbQuery ;
1112 }
13+
14+ public override async testConnection ( ) : Promise < void > {
15+ const { host, port, basic_auth : basicAuth } = this . config ;
16+ const url = `https://${ host } :${ port } /v1/info` ;
17+ const headers : Record < string , string > = { } ;
18+
19+ if ( basicAuth ) {
20+ const { user, password } = basicAuth ;
21+ const encoded = Buffer . from ( `${ user } :${ password } ` ) . toString ( 'base64' ) ;
22+ headers . Authorization = `Basic ${ encoded } ` ;
23+ }
24+
25+ const response = await fetch ( url , { method : 'GET' , headers } ) ;
26+
27+ if ( ! response . ok ) {
28+ const text = await response . text ( ) ;
29+ throw new Error ( `Connection test failed: ${ response . status } ${ response . statusText } - ${ text } ` ) ;
30+ }
31+ }
1232}
You can’t perform that action at this time.
0 commit comments