# Set up the DuckDB Redshift extension and join local files

> Run Redshift SQL from DuckDB 2.0.1, then join the result with a local CSV and write Parquet in one statement.

Source: https://fullbytedeveloper.com/blog/duckdb-redshift-extension-setup
Published here: 2026-12-02

The DuckDB Redshift extension lets a local DuckDB v2.0.1 session run Amazon Redshift SQL and get the result back as a DuckDB table, ready to join with your CSV and Parquet files. [1][2] AWS released it on 2026-12-01 under the Apache License 2.0, and it bundles the Redshift ODBC driver, so there is no driver to install. [1][2]

SQL inside `redshift_query` runs on Redshift's compute, so you can aggregate there and pull only summary rows to the laptop. [1]

Related reading: [query CSV with DuckDB and check totals before you share](/blog/claude-code-for-data-analysis-sql) and [choose tools for working with spreadsheet data](/blog/claude-code-spreadsheet-data-tools). Browse the [Dev tools topic](https://fullbytedeveloper.com/blog/topic/dev-tools).

## Install the extension from the AWS repository

The README registers the AWS extension repository by host name and installs `redshift` from it. DuckDB saves the registration for your user, and `IF NOT EXISTS` makes the first line safe to run again. [1]

```sql
CREATE EXTENSION REPOSITORY IF NOT EXISTS aws.amazon.com;
INSTALL redshift FROM aws.amazon.com;
```

`INSTALL` fails with an HTTP error on a DuckDB version or platform with no build. Builds exist for `linux_amd64`, `linux_arm64`, `osx_arm64`, `osx_amd64` and `windows_amd64`, all for DuckDB v2.0.1. [1]

## Connect with your AWS profile and run one query

In each session, create a DuckDB secret from your AWS profile, attach Redshift, and send a query through `redshift_query`. Replace the profile name and Region with your own. [1]

```sql
CREATE SECRET my_secret (TYPE aws, PROVIDER credential_chain, PROFILE 'my-profile', REGION 'us-east-1');
ATTACH '' AS rs (TYPE redshift, SECRET my_secret);
SELECT * FROM redshift_query('rs', 'SELECT current_user, version()');
```

An empty `ATTACH` target connects to Redshift Serverless with express configuration in the secret's Region, on the `dev` database. AWS describes express configuration as a way to run SQL within seconds without creating a data warehouse first. [1][2]

The README lists three profile cases. [1]

- A profile that keeps its keys in `~/.aws/credentials` works as shown.
- For IAM Identity Center, run `aws sso login --profile my-profile` and add `CHAIN 'sso'` to the secret.
- A profile that uses `credential_process` does not work in this secret. Name it with `CREDENTIAL_PROVIDER profile` instead.

To use your own Serverless workgroup, attach the endpoint the Redshift console shows. The extension reads the Region from it. [1]

```sql
ATTACH 'redshift://my-workgroup.111122223333.us-east-1.redshift-serverless.amazonaws.com/dev'
    AS rs (TYPE redshift, SECRET my_secret);
```

## Aggregate in Redshift and join locally

This is the README's example. The inner query runs on Redshift and returns one row per state; DuckDB then joins those rows with `regions.csv`, totals them by region, and writes Parquet. [1]

```sql
COPY (
    SELECT r.region, sum(s.buyers) AS buyers, sum(s.net_paid) AS net_paid
    FROM redshift_query('rs', $$
        SELECT c.state, count(DISTINCT c.customer_id) AS buyers, sum(s.net_paid) AS net_paid
        FROM "amzn-s3-demo-table-bucket@s3tablescatalog".sales.store_sales s
        JOIN "sales_db@my-warehouse".public.customers c ON c.customer_id = s.customer_id
        WHERE s.sale_date BETWEEN '2022-11-24' AND '2022-11-28'
        GROUP BY c.state $$) s
    JOIN read_csv('regions.csv') r USING (state)
    GROUP BY r.region
    ORDER BY net_paid DESC
) TO 'sales_by_region.parquet' (FORMAT parquet);
```

`regions.csv` needs `state` and `region` columns, one row per state. [1] Replace the catalog and table names with your own. Keep the `GROUP BY` inside the `$$` block: move it out and every sales row crosses the network instead of one row per state.

## Pick Athena on DuckDB for data already in S3

AWS also put Athena on DuckDB in preview on the same day. Per AWS, queries run up to 2x faster and cost up to 50% less on large datasets than Athena version 3, and a separate open-source DuckDB extension for Athena lets you build SQL locally and run it on Athena. [3] The preview covers five Regions: US East (N. Virginia), US East (Ohio), US West (Oregon), Europe (Ireland) and Asia Pacific (Tokyo). [3]

If your tables live in Redshift, use the Redshift extension. If they are files in S3 and you are in one of those Regions, the Athena preview is the one to try, keeping in mind that previews can change.

You now have DuckDB talking to Redshift, a profile setup that matches your sign-in, and a query that does the heavy aggregation in the warehouse and the join on your laptop.

Send this to the analyst who exports Redshift tables to S3 just to read them in DuckDB.

## Sources

1. [aws/duckdb-redshift README](https://github.com/aws/duckdb-redshift)
2. [AWS What's New: Amazon Redshift extension for DuckDB](https://aws.amazon.com/about-aws/whats-new/2026/12/amazon-redshift-duckdb-extension/)
3. [AWS What's New: Amazon Athena powered by DuckDB, preview](https://aws.amazon.com/about-aws/whats-new/2026/12/amazon-athena-now-powered-by-duckdb)
