dbt-redshift
dbt-redshift is the Redshift adapter plugin for dbt (data build tool), enabling data professionals to transform data in Amazon Redshift using SQL. It provides the necessary drivers and specific SQL dialect support to interact with Redshift from a dbt project. As of this entry, the current version is 1.10.1, typically released in sync with dbt-core's quarterly major/minor version updates.
Warnings
- breaking dbt-redshift must be installed with the same minor version as dbt-core (e.g., dbt-core==1.10.x requires dbt-redshift==1.10.x). Mismatched versions will lead to errors.
- gotcha Incorrect or incomplete configuration in `profiles.yml` is a common source of connection errors. This includes wrong `host`, `port`, `user`, `password`, `dbname`, or `schema`.
- gotcha IAM authentication for Redshift requires specific additional parameters in `profiles.yml` (e.g., `iam_duration_seconds`, `iam_user`, `iam_role_arn`, `cluster_id`, `db_user`). Misconfiguration is frequent.
- gotcha Redshift user permissions can prevent dbt from creating schemas or tables. The user configured in `profiles.yml` needs `CREATE` schema/table privileges in the target database.
- gotcha Long-running dbt models might time out if `statement_timeout_in_seconds` is not configured or set too low. The default may vary but can be insufficient for complex transformations.
- gotcha Redshift's support for complex ephemeral materializations (especially deeply nested CTEs or specific window functions) can be limited or lead to performance issues. dbt-redshift sometimes converts them to `views` or `tables` or fails.
Install
-
pip install dbt-redshift
Imports
- Not applicable for end-users
dbt-redshift is an adapter, loaded by dbt-core based on your profiles.yml configuration. End-users typically do not directly import symbols from dbt-redshift in Python code.
Quickstart
# 1. Install dbt-redshift
pip install dbt-redshift
# 2. Initialize a new dbt project
dbt init my_redshift_project
cd my_redshift_project
# 3. Configure profiles.yml (located in ~/.dbt/profiles.yml or dbt project directory)
# Create or edit ~/.dbt/profiles.yml with your Redshift connection details:
# my_redshift_project:
# target: dev
# outputs:
# dev:
# type: redshift
# host: your-redshift-cluster-endpoint.redshift.amazonaws.com
# port: 5439
# user: os.environ.get('REDSHIFT_USER', 'your_user')
# password: os.environ.get('REDSHIFT_PASSWORD', 'your_password')
# dbname: your_database
# schema: your_schema
# threads: 4
# 4. Create a simple dbt model (e.g., models/example/my_first_dbt_model.sql)
# -- models/example/my_first_dbt_model.sql
# select 1 as id, 'hello' as message
# 5. Test the connection and run your model
dbt debug --target dev
dbt run