1.0.*insert_overwrite and appendunique_keypip install dbt-athena-adapterpip install git+https://github.com/Tomme/dbt-athena.gitTo start, you will need an S3 bucket, for instance my-staging-bucket and an Athena database:
CREATE DATABASE IF NOT EXISTS analytics_dev
COMMENT 'Analytics models generated by dbt (development)'
LOCATION 's3://my-staging-bucket/'
WITH DBPROPERTIES ('creator'='Foo Bar', 'email'='foo@bar.com');
Notes:
- Take note of your AWS region code (e.g. us-west-2 or eu-west-2, etc.).
- You can also use AWS Glue to create and manage Athena databases.
This plugin does not accept any credentials directly. Instead, credentials are determined automatically based on aws cli/boto3 conventions and
stored login info. You can configure the AWS profile name to use via aws_profile_name. Checkout DBT profile configuration below for details.
A dbt profile can be configured to run against AWS Athena using the following configuration:
| Option | Description | Required? | Example |
|---|---|---|---|
| s3_staging_dir | S3 location to store Athena query results and metadata | Required | s3://bucket/dbt/ |
| region_name | AWS region of your Athena instance | Required | eu-west-1 |
| schema | Specify the schema (Athena database) to build models into (lowercase only) | Required | dbt |
| database | Specify the database (Data catalog) to build models into (lowercase only) | Required | awsdatacatalog |
| poll_interval | Interval in seconds to use for polling the status of query results in Athena | Optional | 5 |
| aws_profile_name | Profile to use from your AWS shared credentials file. | Optional | my-profile |
| work_group | Identifier of Athena workgroup | Optional | my-custom-workgroup |
| num_retries | Number of times to retry a failing query | Optional | 3 |
Example profiles.yml entry:
athena:
target: dev
outputs:
dev:
type: athena
s3_staging_dir: s3://athena-query-results/dbt/
region_name: eu-west-1
schema: dbt
database: awsdatacatalog
aws_profile_name: my-profile
work_group: my-workgroup
Additional information
* threads is supported
* database and catalog can be used interchangeably
external_location (default=none)none then it will default to {s3_staging_dir}/tablespartitioned_by (default=none)bucketed_by (default=none)bucket_count (default=none)format (default='parquet')ORC, PARQUET, AVRO, JSON, or TEXTFILEwrite_compression (default=none)field_delimiter (default=none)TEXTFILEMore information: CREATE TABLE AS
Support for incremental models:
* Support two incremental update strategies with partitioned tables: insert_overwrite and append
* Does not support the use of unique_key
Due to the nature of AWS Athena, not all core dbt functionality is supported. The following features of dbt are not implemented on Athena: * Snapshots
```yaml version: 2
sources: - name: my_source tables: - name: first_table identifier: "first table" # Not like that - name: second_table identifier: "\"second table\"" # Like this ```
First, install the adapter and its dependencies using make (see Makefile):
make install_deps
Next, configure the environment variables in dev.env to match your Athena development environment. Finally, run the tests using make:
make run_tests
$ claude mcp add dbt-athena \
-- python -m otcore.mcp_server <graph>