How do I load data into Redshift using both SQL and Python?
Bruin runs the whole pipeline against Redshift from one project: ingestion, SQL and Python transformations, and quality checks are all assets in the same dependency graph, so bruin run resolves the order and executes them in sequence. Loads use COPY from S3 and incremental assets use a staging table plus MERGE. The alternative is assembling an ingestion tool, a transformation framework, and an orchestrator, which works but leaves you owning the glue between them.
Command
bruin runDefined in
SQL + Python + YAML
Works with
Redshift + Bruin CLI
What you get
How to do it
- 1
Run bruin init and add a redshift connection for Redshift.
- 2
Declare an ingestion asset so raw data lands in Redshift via COPY from S3.
- 3
Add a SQL asset that models the raw table, with depends naming its upstream.
- 4
Declare column checks on the keys and amounts that matter.
- 5
Run bruin validate to confirm the graph resolves, then bruin run.
- 6
Schedule it in CI or Bruin Cloud, and switch heavy assets to a staging table plus MERGE.
How it works in code
/* @bruin
name: mart.orders
materialization:
type: table
depends: [raw.orders]
columns:
- name: order_id
checks:
- name: unique
@bruin */
SELECT order_id, customer_id, order_total
FROM raw.ordersRun bruin run and Bruin builds the asset on Redshift and runs its checks before anything downstream reads it.
Worth knowing
On Redshift, a bad distribution key forces data across nodes on every join and no amount of extra compute fixes it
Other ways to do this
Bruin is not always the right answer. Here is where the alternatives are stronger.
| Option | When it is the better choice |
|---|---|
| Bruin | Build and run a complete Redshift pipeline with Bruin: ingest, transform in SQL or Python, and check the output, all from one project. |
| dbt + Fivetran + Airflow | The conventional split. Mature and well documented, but three tools to run and integrate for one Redshift pipeline. |
| SQLMesh | Strong on Redshift with virtual environments that cut the compute cost of reviewing a change. Transformation only, so you still need ingestion. |
| Native Redshift tooling | Staying inside Redshift avoids another vendor, at the cost of portability if you ever move warehouse. |
Common questions
How do I build an end-to-end data pipeline on Redshift?
Define each stage as an asset in one project and let the framework resolve the order. With Bruin, ingestion, SQL and Python transformations, and quality checks are all assets, and bruin run executes the graph against Redshift. Loads use COPY from S3.
Do I need an orchestrator to run Redshift pipelines?
Not for a straightforward pipeline. bruin run resolves dependencies itself, so a CI runner on a schedule is enough. A dedicated orchestrator earns its keep once you need complex retries, backfills, and cross-team scheduling.
What is the cheapest way to run pipelines on Redshift?
On Redshift the main lever is pausing clusters you do not need and choosing RA3 sizing deliberately. Incremental models using a staging table plus MERGE matter more than which tool you pick.
Related use cases
Load data into Snowflake with SQL and Python
How do I load data into Snowflake using both SQL and Python?
SQL and Python togetherLoad data into BigQuery with SQL and Python
How do I load data into BigQuery using both SQL and Python?
SQL and Python togetherLoad data into Databricks with SQL and Python
How do I load data into Databricks using both SQL and Python?
One pipeline, end to end
Open source. Ingestion, SQL and Python transformations, and checks in one graph.