September 16, 2024

Install the Adapter for Athena with dbt Developer Hub

Use pip to install adapter for Athena & configure profile with AWS credentials & S3 locations for results & tables. Build models in your Athena database.
Dexter Chu
Head of Marketing

How to Install the Adapter for Athena with dbt Developer Hub?

Setting up Athena with dbt Developer Hub begins with the installation of the adapter. This is done using pip, a package installer for Python. Pip allows you to install and manage additional packages that are not part of the Python standard library.

python -m pip install adapter-name

The above code is a general command for installing any adapter. For instance, to install Snowflake, you would replace 'adapter-name' with 'dbt-snowflake'. The installation will include dbt-core and any other required dependencies.

  • pip: A package installer for Python
  • adapter-name: The name of the adapter you want to install
  • dbt-core: The core dbt package that will be installed alongside the adapter

How to Configure Your Profile to Run Against AWS Athena?

After installing the adapter, the next step is to configure your profile to run against AWS Athena. This involves setting up your AWS credentials and specifying certain parameters such as the AWS region of your Athena instance and the Athena database (schema) to build models into.

// Code example for configuring profile

The code above is a placeholder for the actual code needed to configure your profile. The exact code will depend on your specific AWS credentials and the parameters you need to specify.

  • AWS credentials: Your access key ID and secret access key for AWS
  • AWS region: The region where your Athena instance is located
  • Athena database (schema): The database or schema where you want to build your models

How to Store Athena Query Results and Metadata in the S3 Location?

Once your profile is configured, you can then specify the S3 location where Athena query results and metadata will be stored. This is done using the 's3_staging_dir' parameter.

// Code example for storing Athena query results and metadata

The code above is a placeholder for the actual code needed to store Athena query results and metadata in the S3 location. The exact code will depend on your specific 's3_staging_dir' parameter.

  • s3_staging_dir: The S3 location where Athena query results and metadata will be stored

How to Store Tables in the Prefix Specified by s3_data_dir?

Another important step in setting up Athena with dbt Developer Hub is storing tables in the prefix specified by 's3_data_dir'. This involves specifying the S3 location where your tables will be stored.

// Code example for storing tables in the prefix

The code above is a placeholder for the actual code needed to store tables in the prefix specified by 's3_data_dir'. The exact code will depend on your specific 's3_data_dir' parameter.

  • s3_data_dir: The S3 location where your tables will be stored

How to Specify the Database to Build Models into?

The final step in setting up Athena with dbt Developer Hub is specifying the database (data catalog) to build models into. This is done using the 'database' parameter.

// Code example for specifying the database

The code above is a placeholder for the actual code needed to specify the database to build models into. The exact code will depend on your specific 'database' parameter.

  • database: The database (data catalog) where you want to build your models

Keep reading

View all