Skip to content

Commit

Permalink
wip: add azure export bucket options to Snowflake driver
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Sep 19, 2024
1 parent ab3771b commit 0dab1e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/cubejs-backend-shared/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ const variables: Record<string, (...args: any) => any> = {
),

/**
* AWS Region for the AWS based export bucket srorage.
* AWS Region for the AWS based export bucket storage.
*/
dbExportBucketAwsRegion: ({
dataSource,
Expand All @@ -757,7 +757,7 @@ const variables: Record<string, (...args: any) => any> = {
),

/**
* Azure Key for the Azure based export bucket srorage.
* Azure Key for the Azure based export bucket storage.
*/
dbExportBucketAzureKey: ({
dataSource,
Expand Down
22 changes: 19 additions & 3 deletions packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ interface SnowflakeDriverExportGCS {
credentials: any,
}

export type SnowflakeDriverExportBucket = SnowflakeDriverExportAWS | SnowflakeDriverExportGCS;
interface SnowflakeDriverExportAzure {
bucketType: 'azure',
bucketName: string,
keyId: string,
credentials: any,
}

export type SnowflakeDriverExportBucket = SnowflakeDriverExportAWS | SnowflakeDriverExportGCS | SnowflakeDriverExportAzure;

interface SnowflakeDriverOptions {
account: string,
Expand Down Expand Up @@ -295,8 +302,17 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
};
}

if (bucketType === 'azure') {
return {
bucketType,
bucketName: getEnv('dbExportBucket', { dataSource }),
keyId: getEnv('dbExportBucketAzureKey', { dataSource }),
credentials: getEnv('dbExportAzureCredentials', { dataSource }),
};
}

throw new Error(
`Unsupported EXPORT_BUCKET_TYPE, supported: ${['s3', 'gcs'].join(',')}`
`Unsupported EXPORT_BUCKET_TYPE, supported: ${['s3', 'gcs', 'azure'].join(',')}`
);
}

Expand All @@ -308,7 +324,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
): SnowflakeDriverExportBucket | undefined {
const bucketType = getEnv('dbExportBucketType', {
dataSource,
supported: ['s3', 'gcs'],
supported: ['s3', 'gcs', 'azure'],
});
if (bucketType) {
const exportBucket = this.createExportBucket(
Expand Down

0 comments on commit 0dab1e8

Please sign in to comment.