Home

Awesome

dbt-athena

Installation

Prerequisites

To 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:

Credentials

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.

Configuring your profile

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

OptionDescriptionRequired?Example
s3_staging_dirS3 location to store Athena query results and metadataRequireds3://bucket/dbt/
region_nameAWS region of your Athena instanceRequiredeu-west-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 AthenaOptional5
aws_profile_nameProfile to use from your AWS shared credentials file.Optionalmy-profile
work_groupIdentifier of Athena workgroupOptionalmy-custom-workgroup
num_retriesNumber of times to retry a failing queryOptional3

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

Usage notes

Models

Table Configuration

More information: CREATE TABLE AS

Supported functionality

Support for incremental models:

Due to the nature of AWS Athena, not all core dbt functionality is supported. The following features of dbt are not implemented on Athena:

Known issues

Running tests

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

Community