Skip to content

Commit 834d381

Browse files
feat(athena-driver): Add option for providing default database to use (#9735)
* feat(athena-driver): add session-token and database env vars * update Athena driver docs * fix comment * chore: use CUBEJS_DB_NAME for Athena default database * chore: revert doc changes * chore: revert add env to aws access token * update docs * fix settings --------- Co-authored-by: paulorsbrito <[email protected]>
1 parent 7987b75 commit 834d381

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

docs/pages/product/configuration/data-sources/aws-athena.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CUBEJS_AWS_SECRET=****************************************
2020
CUBEJS_AWS_REGION=us-east-1
2121
CUBEJS_AWS_S3_OUTPUT_LOCATION=s3://my-athena-output-bucket
2222
CUBEJS_AWS_ATHENA_WORKGROUP=primary
23+
CUBEJS_DB_NAME=my_non_default_athena_database
2324
CUBEJS_AWS_ATHENA_CATALOG=AwsDataCatalog
2425
```
2526

@@ -59,8 +60,9 @@ if [dedicated infrastructure][ref-dedicated-infra] is used. Check out the
5960
| `CUBEJS_AWS_S3_OUTPUT_LOCATION` | The S3 path to store query results made by the Cube deployment | A valid S3 path ||
6061
| `CUBEJS_AWS_ATHENA_WORKGROUP` | The name of the workgroup in which the query is being started | [A valid Athena Workgroup][aws-athena-workgroup] ||
6162
| `CUBEJS_AWS_ATHENA_CATALOG` | The name of the catalog to use by default | [A valid Athena Catalog name][awsdatacatalog] ||
63+
| `CUBEJS_DB_NAME` | The name of the database to use by default | A valid Athena Database name ||
6264
| `CUBEJS_DB_SCHEMA` | The name of the schema to use as `information_schema` filter. Reduces count of tables loaded during schema generation. | A valid schema name ||
63-
| `CUBEJS_CONCURRENCY` | The number of [concurrent queries][ref-data-source-concurrency] to the data source | A valid number ||
65+
| `CUBEJS_CONCURRENCY` | The number of [concurrent queries][ref-data-source-concurrency] to the data source | A valid number ||
6466

6567
[ref-data-source-concurrency]: /product/configuration/concurrency#data-source-concurrency
6668

@@ -148,4 +150,4 @@ connections are made over HTTPS.
148150
[ref-caching-using-preaggs-build-strats]:
149151
/product/caching/using-pre-aggregations#pre-aggregation-build-strategies
150152
[ref-schema-ref-types-formats-countdistinctapprox]: /product/data-modeling/reference/types-and-formats#count_distinct_approx
151-
[self-preaggs-batching]: #batching
153+
[self-preaggs-batching]: #batching

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ interface AthenaDriverOptions extends AthenaClientConfig {
4545
workGroup?: string
4646
catalog?: string
4747
schema?: string
48+
database?: string
4849
S3OutputLocation?: string
4950
exportBucket?: string
5051
pollTimeout?: number
@@ -147,6 +148,9 @@ export class AthenaDriver extends BaseDriver implements DriverInterface {
147148
catalog:
148149
config.catalog ||
149150
getEnv('athenaAwsCatalog', { dataSource }),
151+
database:
152+
config.database ||
153+
getEnv('dbName', { dataSource }),
150154
exportBucket:
151155
config.exportBucket ||
152156
getEnv('dbExportBucket', { dataSource }),
@@ -477,7 +481,12 @@ export class AthenaDriver extends BaseDriver implements DriverInterface {
477481
ResultConfiguration: {
478482
OutputLocation: this.config.S3OutputLocation
479483
},
480-
...(this.config.catalog != null ? { QueryExecutionContext: { Catalog: this.config.catalog } } : {})
484+
...(this.config.catalog || this.config.database ? {
485+
QueryExecutionContext: {
486+
Catalog: this.config.catalog,
487+
Database: this.config.database
488+
}
489+
} : {})
481490
};
482491
const { QueryExecutionId } = await this.athena.startQueryExecution(request);
483492
return { QueryExecutionId: checkNonNullable('StartQueryExecution', QueryExecutionId) };

0 commit comments

Comments
 (0)