dbt-athena

1.10.0 · active · verified Sun Apr 12

dbt-athena is an adapter plugin for dbt (data build tool) that enables data analysts and engineers to transform data in Amazon Athena, a serverless query service for S3 data, using SQL. It is currently at version 1.10.0 and is actively maintained by dbt Labs. The library generally follows semantic versioning with frequent patch releases, minor versions adding backward-compatible features, and major versions potentially introducing breaking changes.

Warnings

Install

Imports

Quickstart

This quickstart outlines the steps to set up a dbt project with the dbt-athena adapter. It involves installing the necessary packages, initializing a dbt project, configuring your AWS Athena connection details in `profiles.yml`, and then running `dbt` commands to test and execute your models. Ensure you have an S3 bucket for query results and an Athena database set up in AWS.

# 1. Install dbt-athena and dbt-core
pip install dbt-core dbt-athena

# 2. Initialize a new dbt project (follow prompts, select 'athena' as database type)
dbt init my_athena_project

# 3. Configure your profiles.yml (e.g., ~/.dbt/profiles.yml or project_root/profiles.yml)
# Example profiles.yml content:
# my_athena_project:
#   target: dev
#   outputs:
#     dev:
#       type: athena
#       s3_staging_dir: s3://your-athena-query-results-bucket/dbt-staging/
#       region_name: us-east-1
#       database: your_athena_database
#       schema: dbt_schema
#       threads: 4
#       aws_profile_name: default # Or use aws_access_key_id and aws_secret_access_key

# 4. Create an S3 bucket and Athena database as prerequisites
# (AWS CLI/Console steps, not Python code):
#   aws s3 mb s3://your-athena-query-results-bucket
#   aws athena create-data-catalog --name your_athena_database --type LAMBDA --parameters "catalog-id"="your_glue_catalog_id" # Or simply use an existing database

# 5. Create a sample dbt model (e.g., my_athena_project/models/my_first_model.sql)
# -- my_athena_project/models/my_first_model.sql
# select 1 as id, 'hello' as message

# 6. Test the connection and run your dbt project
dbt debug --target dev
dbt run --target dev

view raw JSON →