@@ -53,6 +53,9 @@ export type PrestoDriverConfiguration = PrestoDriverExportBucket & {
5353 dataSource ?: string ;
5454 queryTimeout ?: number ;
5555 preAggregations ?: boolean ;
56+ useSelectTestConnection ?: boolean ;
57+ // @see https://trino.io/docs/current/develop/client-protocol.html
58+ headers ?: Record < string , string > ;
5659} ;
5760
5861const SUPPORTED_BUCKET_TYPES = [ 'gcs' , 's3' ] ;
@@ -94,7 +97,8 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
9497 throw new Error ( 'Both user/password and auth token are set. Please remove password or token.' ) ;
9598 }
9699
97- this . useSelectTestConnection = getEnv ( 'dbUseSelectTestConnection' , { dataSource, preAggregations } ) ;
100+ this . useSelectTestConnection = config . useSelectTestConnection ??
101+ getEnv ( 'dbUseSelectTestConnection' , { dataSource, preAggregations } ) ;
98102
99103 this . config = {
100104 host : getEnv ( 'dbHost' , { dataSource, preAggregations } ) ,
@@ -174,6 +178,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
174178 this . client . execute ( {
175179 query,
176180 schema : this . config . schema || 'default' ,
181+ headers : this . config . headers ,
177182 session : this . config . queryTimeout ? `query_max_run_time=${ this . config . queryTimeout } s` : undefined ,
178183 columns : ( error : any , columns : TableStructure ) => {
179184 resolve ( {
@@ -202,6 +207,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
202207 this . client . execute ( {
203208 query,
204209 schema : this . config . schema || 'default' ,
210+ headers : this . config . headers ,
205211 data : ( error : any , data : any [ ] , columns : TableStructure ) => {
206212 const normalData = this . normalizeResultOverColumns ( data , columns ) ;
207213 fullData = concat ( normalData , fullData ) ;
@@ -312,9 +318,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
312318 }
313319
314320 if ( ! SUPPORTED_BUCKET_TYPES . includes ( this . config . bucketType as string ) ) {
315- throw new Error ( `Unsupported export bucket type: ${
316- this . config . bucketType
317- } `) ;
321+ throw new Error ( `Unsupported export bucket type: ${ this . config . bucketType } ` ) ;
318322 }
319323
320324 const types = options . query
@@ -336,7 +340,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
336340 return { schema, tableName } ;
337341 }
338342
339- private generateTableColumnsForExport ( types : { name : string , type : string } [ ] ) {
343+ private generateTableColumnsForExport ( types : { name : string , type : string } [ ] ) {
340344 return types . map ( ( c ) => `CAST(${ c . name } AS varchar) ${ c . name } ` ) . join ( ', ' ) ;
341345 }
342346
@@ -360,7 +364,7 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
360364 } ) ;
361365 }
362366
363- private async unloadGeneric ( params : { tableFullName : string , typeSql : string , typeParams : any [ ] , fromSql : string , fromParams : any [ ] } ) {
367+ private async unloadGeneric ( params : { tableFullName : string , typeSql : string , typeParams : any [ ] , fromSql : string , fromParams : any [ ] } ) {
364368 if ( ! this . config . exportBucket ) {
365369 throw new Error ( 'Export bucket is not configured.' ) ;
366370 }
0 commit comments