Skip to main content

Installing dbt-athena

Prerequisites

  • Installed dbt Core using the installation instructions for your operating system + a dbt project initialized.
  • A working Athena setup.

Install dbt-athena

Pip is the easiest way to install the dbt-athena-community package in your dbt project:

pip install dbt-athena-community

Configuring dbt-athena

A dbt profile can be configured in the profiles.yml to run against AWS Athena using the following configuration:

OptionDescriptionRequired?Example
s3_staging_dirS3 location to store Athena query results and metadataRequireds3://bucket/dbt/
s3_data_dirPrefix for storing tables, if different from the connection's s3_staging_dirOptionals3://bucket2/dbt/
s3_data_namingHow to generate table paths in s3_data_dir. Default: schema_table_unique. See Table ConfigurationOptionalschema_table_unique
region_nameAWS region of your Athena instanceRequiredeu-central-1
schemaSpecify the schema (Athena database) to build models into (lowercase only)Requireddbt
databaseSpecify the database (Data catalog) to build models into (lowercase only)Requiredawsdatacatalog
poll_intervalInterval in seconds to use for polling the status of query results in Athena. Default: 1Optional5
aws_profile_nameProfile to use from your AWS shared credentials file.Optionalmy-profile
aws_access_key_idAWS access key to sign AWS API requests. This is optional, as credentials are determined automatically based on the aws cli and boto3 conventions and stored login info.OptionalAKIAIOSFODNN7EXAMPLE
aws_secret_access_keyAWS secret access key to sign AWS API requests. This is optional, as credentials are determined automatically based on the aws cli and boto3 conventions and stored login info.OptionalwJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
work_groupIdentifier of Athena workgroupOptionalmy-custom-workgroup
num_retriesNumber of times to retry a failing query. Default: 5Optional3
lf_tagsLF tags to apply to any database created by dbtOptional{"origin": "dbt", "team": "analytics"}

Example profiles.yml entry:

athena:
target: dev
outputs:
dev:
type: athena
work_group: primary
s3_staging_dir: s3://aws-athena-query-results/dbt/
s3_data_dir: s3://your_s3_bucket/dbt/
s3_data_naming: schema_table_unique
region_name: eu-central-1
database: awsdatacatalog
schema: dbt
aws_profile_name: my-profile
lf_tags:
origin: dbt
team: analytics
threads: 8

Additional information

  • threads is supported
  • database and catalog can be used interchangeably
0