@@ -32,6 +32,9 @@ export type PrestoDriverExportBucket = {
3232 exportBucket ?: string ,
3333 bucketType ?: 'gcs' | 's3' ,
3434 credentials ?: any ,
35+ accessKeyId ?: string ,
36+ secretAccessKey ?: string ,
37+ exportBucketRegion ?: string ,
3538 exportBucketCsvEscapeSymbol ?: string ,
3639} ;
3740
@@ -105,6 +108,9 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
105108 ssl : this . getSslOptions ( dataSource ) ,
106109 bucketType : getEnv ( 'dbExportBucketType' , { supported : SUPPORTED_BUCKET_TYPES , dataSource } ) ,
107110 exportBucket : getEnv ( 'dbExportBucket' , { dataSource } ) ,
111+ accessKeyId : getEnv ( 'dbExportBucketAwsKey' , { dataSource } ) ,
112+ secretAccessKey : getEnv ( 'dbExportBucketAwsSecret' , { dataSource } ) ,
113+ exportBucketRegion : getEnv ( 'dbExportBucketAwsRegion' , { dataSource } ) ,
108114 credentials : getEnv ( 'dbExportGCSCredentials' , { dataSource } ) ,
109115 ...config
110116 } ;
@@ -312,7 +318,11 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
312318
313319 const { schema, tableName } = this . splitTableFullName ( params . tableFullName ) ;
314320 const tableWithCatalogAndSchema = `${ this . config . catalog } .${ schema } .${ tableName } ` ;
315- const protocol = bucketType === 'gcs' ? 'gs' : bucketType ;
321+ let protocol = bucketType === 'gcs' ? 'gs' : bucketType ;
322+ if ( bucketType === 's3' ) {
323+ protocol = 's3a' ;
324+ }
325+
316326 const externalLocation = `${ protocol } ://${ exportBucket } /${ schema } /${ tableName } ` ;
317327 const withParams = `( external_location = '${ externalLocation } ', format = 'CSV')` ;
318328 const select = `SELECT ${ this . generateTableColumnsForExport ( types ) } FROM (${ params . fromSql } )` ;
@@ -345,14 +355,21 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
345355 if ( ! this . config . exportBucket ) {
346356 throw new Error ( 'Export bucket is not configured.' ) ;
347357 }
348- const { bucketType, exportBucket, credentials } = this . config ;
358+ const { bucketType, exportBucket } = this . config ;
349359 const { schema, tableName } = this . splitTableFullName ( tableFullName ) ;
350360
351361 switch ( bucketType ) {
352362 case 'gcs' :
353- return this . extractFilesFromGCS ( { credentials } , exportBucket , `${ schema } /${ tableName } ` ) ;
363+ return this . extractFilesFromGCS ( { credentials : this . config . credentials } , exportBucket , `${ schema } /${ tableName } ` ) ;
354364 case 's3' :
355- return this . extractUnloadedFilesFromS3 ( { credentials } , exportBucket , `${ schema } /${ tableName } ` ) ;
365+ return this . extractUnloadedFilesFromS3 ( {
366+ credentials : {
367+ accessKeyId : this . config . accessKeyId || '' ,
368+ secretAccessKey : this . config . secretAccessKey || '' ,
369+ } ,
370+ region : this . config . exportBucketRegion ,
371+ } ,
372+ exportBucket , `${ schema } /${ tableName } ` ) ;
356373 default :
357374 throw new Error ( `Unsupported export bucket type: ${ bucketType } ` ) ;
358375 }
0 commit comments