@@ -721,10 +721,6 @@ export class DatabricksDriver extends JDBCDriver {
721721 // s3://real-bucket-name
722722723723 // The extractors in BaseDriver expect just clean bucket name
724- const url = new URL ( this . config . exportBucket || '' ) ;
725- const prefix = url . pathname . slice ( 1 ) ;
726- const delimiter = ( prefix && ! prefix . endsWith ( '/' ) ) ? '/' : '' ;
727- const objectSearchPrefix = `${ prefix } ${ delimiter } ${ tableName } ` ;
728724
729725 if ( this . config . bucketType === 'azure' ) {
730726 const {
@@ -733,14 +729,22 @@ export class DatabricksDriver extends JDBCDriver {
733729 azureTenantId : tenantId ,
734730 azureClientSecret : clientSecret
735731 } = this . config ;
732+
733+ const { bucketName, path, username } = this . parseBucketUrl ( this . config . exportBucket ) ;
734+ const azureBucketPath = `${ bucketName } /${ username } ` ;
735+ const exportPrefix = path ? `${ path } /${ tableName } ` : tableName ;
736+
736737 return this . extractFilesFromAzure (
737738 { azureKey, clientId, tenantId, clientSecret } ,
738739 // Databricks uses different bucket address form, so we need to transform it
739740 // to the one understandable by extractFilesFromAzure implementation
740- ` ${ url . host } / ${ url . username } ` ,
741- objectSearchPrefix ,
741+ azureBucketPath ,
742+ exportPrefix ,
742743 ) ;
743744 } else if ( this . config . bucketType === 's3' ) {
745+ const { bucketName, path } = this . parseBucketUrl ( this . config . exportBucket ) ;
746+ const exportPrefix = path ? `${ path } /${ tableName } ` : tableName ;
747+
744748 return this . extractUnloadedFilesFromS3 (
745749 {
746750 credentials : {
@@ -749,14 +753,17 @@ export class DatabricksDriver extends JDBCDriver {
749753 } ,
750754 region : this . config . awsRegion || '' ,
751755 } ,
752- url . host ,
753- objectSearchPrefix ,
756+ bucketName ,
757+ exportPrefix ,
754758 ) ;
755759 } else if ( this . config . bucketType === 'gcs' ) {
760+ const { bucketName, path } = this . parseBucketUrl ( this . config . exportBucket ) ;
761+ const exportPrefix = path ? `${ path } /${ tableName } ` : tableName ;
762+
756763 return this . extractFilesFromGCS (
757764 { credentials : this . config . gcsCredentials } ,
758- url . host ,
759- objectSearchPrefix ,
765+ bucketName ,
766+ exportPrefix ,
760767 ) ;
761768 } else {
762769 throw new Error ( `Unsupported export bucket type: ${
0 commit comments