Skip to content

Commit 141cdad

Browse files
committed
feat: Support pre-aggregation-specific data source credentials (CORE-123)
refactor: Replace envVar helper with getVar in env.ts refactor: Remove getVar helper, inline get(keyByDataSource(...)) directly
1 parent 515eeae commit 141cdad

33 files changed

Lines changed: 1044 additions & 983 deletions

File tree

packages/cubejs-athena-driver/src/AthenaDriver.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ export class AthenaDriver extends BaseDriver implements DriverInterface {
9999
*/
100100
dataSource?: string,
101101

102+
/**
103+
* Whether this driver is used for pre-aggregations.
104+
*/
105+
preAggregations?: boolean,
106+
102107
/**
103108
* Max pool size value for the [cube]<-->[db] pool.
104109
*/
@@ -118,28 +123,29 @@ export class AthenaDriver extends BaseDriver implements DriverInterface {
118123
const dataSource =
119124
config.dataSource ||
120125
assertDataSource('default');
126+
const preAggregations = config.preAggregations || false;
121127

122128
const accessKeyId =
123129
config.accessKeyId ||
124-
getEnv('athenaAwsKey', { dataSource });
130+
getEnv('athenaAwsKey', { dataSource, preAggregations });
125131

126132
const secretAccessKey =
127133
config.secretAccessKey ||
128-
getEnv('athenaAwsSecret', { dataSource });
134+
getEnv('athenaAwsSecret', { dataSource, preAggregations });
129135

130136
const assumeRoleArn =
131137
config.athenaAwsAssumeRoleArn ||
132-
getEnv('athenaAwsAssumeRoleArn', { dataSource });
138+
getEnv('athenaAwsAssumeRoleArn', { dataSource, preAggregations });
133139

134140
const assumeRoleExternalId =
135141
config.athenaAwsAssumeRoleExternalId ||
136-
getEnv('athenaAwsAssumeRoleExternalId', { dataSource });
142+
getEnv('athenaAwsAssumeRoleExternalId', { dataSource, preAggregations });
137143

138144
const { schema, ...restConfig } = config;
139145

140146
this.schema = schema ||
141-
getEnv('dbName', { dataSource }) ||
142-
getEnv('dbSchema', { dataSource });
147+
getEnv('dbName', { dataSource, preAggregations }) ||
148+
getEnv('dbSchema', { dataSource, preAggregations });
143149

144150
// Configure credentials based on authentication method
145151
let credentials;
@@ -166,34 +172,34 @@ export class AthenaDriver extends BaseDriver implements DriverInterface {
166172
...restConfig,
167173
region:
168174
config.region ||
169-
getEnv('athenaAwsRegion', { dataSource }),
175+
getEnv('athenaAwsRegion', { dataSource, preAggregations }),
170176
S3OutputLocation:
171177
config.S3OutputLocation ||
172-
getEnv('athenaAwsS3OutputLocation', { dataSource }),
178+
getEnv('athenaAwsS3OutputLocation', { dataSource, preAggregations }),
173179
workGroup:
174180
config.workGroup ||
175-
getEnv('athenaAwsWorkgroup', { dataSource }) ||
181+
getEnv('athenaAwsWorkgroup', { dataSource, preAggregations }) ||
176182
'primary',
177183
catalog:
178184
config.catalog ||
179-
getEnv('athenaAwsCatalog', { dataSource }),
185+
getEnv('athenaAwsCatalog', { dataSource, preAggregations }),
180186
database:
181187
config.database ||
182-
getEnv('dbName', { dataSource }),
188+
getEnv('dbName', { dataSource, preAggregations }),
183189
exportBucket:
184190
config.exportBucket ||
185-
getEnv('dbExportBucket', { dataSource }),
191+
getEnv('dbExportBucket', { dataSource, preAggregations }),
186192
pollTimeout: (
187193
config.pollTimeout ||
188-
getEnv('dbPollTimeout', { dataSource }) ||
189-
getEnv('dbQueryTimeout', { dataSource })
194+
getEnv('dbPollTimeout', { dataSource, preAggregations }) ||
195+
getEnv('dbQueryTimeout', { dataSource, preAggregations })
190196
) * 1000,
191197
pollMaxInterval: (
192198
config.pollMaxInterval ||
193-
getEnv('dbPollMaxInterval', { dataSource })
199+
getEnv('dbPollMaxInterval', { dataSource, preAggregations })
194200
) * 1000,
195201
exportBucketCsvEscapeSymbol:
196-
getEnv('dbExportBucketCsvEscapeSymbol', { dataSource }),
202+
getEnv('dbExportBucketCsvEscapeSymbol', { dataSource, preAggregations }),
197203
};
198204
if (this.config.exportBucket) {
199205
this.config.exportBucket =

0 commit comments

Comments
 (0)