How to Load Data Into Redshift With dbt

To load data into Redshift with dbt, write a SQL model that selects from your raw table, applies transforms, and run dbt run - dbt materializes it as a table automatically. The project wires the connection; you write the SQL.

Data Engineerdbtredshiftpostgres

How dbt loads data into Redshift

dbt (data build tool) is not an ingestion layer - it transforms data that is already in the warehouse. You write a .sql file in models/, run dbt run, and dbt executes your SELECT and materializes the result as a table (or view) in the database. Redshift and Postgres share the same SQL dialect for everything dbt touches, so dbt-postgres and dbt-redshift are interchangeable at the model level.

The model file

A dbt model is just a SELECT. Put it in models/orders.sql:

SELECT
  order_id,
  customer_id,
  total_cents / 100.0 AS total_dollars
FROM raw_orders
WHERE status = 'completed'

That is the complete model. dbt reads the file, wraps it in a CREATE TABLE AS (because materialized = 'table' is set in dbt_project.yml), and runs it against the warehouse.

Running the model

cd /workspace
dbt run

dbt prints each model name and whether it succeeded:

Running with dbt=1.x.x
Found 1 model, 0 tests
Concurrency: 1 threads

1 of 1 START table model public.orders ........................ [RUN]
1 of 1 OK created table model public.orders .................. [SELECT 3 in 0.12s]

Finished running 1 table model in 0.21s.
Completed successfully.

To inspect the result directly:

psql -h 127.0.0.1 -U postgres -d app -c "SELECT * FROM orders;"

Project wiring

Two config files connect the model to the warehouse:

DBT_PROFILES_DIR=/workspace dbt run

Staging, intermediate, and marts

In production dbt projects, you layer models:

Models reference each other with ref() so dbt builds the full DAG and runs them in dependency order:

-- models/orders.sql (mart referencing a staging model)
SELECT
  order_id,
  customer_id,
  total_cents / 100.0 AS total_dollars
FROM {{ ref('stg_orders') }}
WHERE status = 'completed'

Add dbt test to catch not_null and unique violations on every run.

Want to try it hands-on? HeyDevJob gives you this exact setup in a live cloud workspace in your browser - edit it, run it, and see it work. Free, nothing to install.

Try it in a workspace →

What you'll practice

FAQ

How does dbt load data into Redshift?

dbt transforms data already in Redshift - you write a SELECT in a .sql model file, run dbt run, and dbt materializes the result as a table or view in the warehouse. It does not ingest raw data from outside the database.

What is the difference between dbt-postgres and dbt-redshift?

For standard SQL models - filters, joins, casts, aggregations - the SQL is identical. dbt-redshift adds Redshift-specific materializations like sort_key and dist_key. If your model is plain SQL, dbt-postgres works against a Redshift-compatible Postgres endpoint.

How do I reference one dbt model from another?

Use {{ ref('model_name') }} in your SELECT instead of the raw table name. dbt resolves the reference, builds a dependency graph (DAG), and runs models in the correct order.

Can you use dbt with Redshift?

Yes. dbt has a native Redshift adapter (dbt-redshift). You write SQL models and dbt run materializes them as tables or views in Redshift, just like any other warehouse.

Keep learning

Make an ETL Pipeline IdempotentData projectSpeed Up a Slow SQL Report QueryData projectMake a CSV Importer Resilient to Bad DataData projectData roadmapStep by step to hiredData interview questionsSTAR answersAll Data projectsProjects hub

Learn it by doing. Open this in a live cloud workspace, make the change yourself, and keep a record of the work you can share.

Open the workspace →