How to Migrate from Redshift to BigQuery in PostgreSQL

Galaxy Glossary

How do I migrate data from Amazon Redshift to Google BigQuery?

Export data from Amazon Redshift and import it into Google BigQuery with minimal downtime and schema fidelity.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why migrate from Redshift to BigQuery?

Lower maintenance, serverless scalability, and native BI integration often justify the switch. BigQuery’s pay-as-you-go model eliminates cluster tuning and vacuuming tasks.

What are the high-level steps?

1) Extract data from Redshift to Amazon S3, 2) Transfer files to Google Cloud Storage (GCS), 3) Load data into BigQuery, 4) Validate and cut over.

How do I export Redshift tables quickly?

Use UNLOAD to write compressed, partitioned Parquet files to S3.Parquet preserves types and speeds BigQuery loading.

UNLOAD ('SELECT * FROM customers')
TO 's3://my-bucket/migration/customers_'
FORMAT AS PARQUET
PARALLEL ON
ALLOWOVERWRITE;

How do I transfer files from S3 to GCS?

gsutil rsync copies entire folders while preserving file names and compression. Ensure IAM roles allow cross-cloud access or download and re-upload locally.

gsutil rsync -r s3://my-bucket/migration gs://my-gcs-bucket/migration

What is the BigQuery load command?

bq load ingests Parquet files into native tables.Use wildcard URIs for partitioned exports.

bq load --source_format=PARQUET ecommerce.customers \
gs://my-gcs-bucket/migration/customers_*

How do I preserve primary keys and constraints?

BigQuery lacks traditional PK constraints. Emulate uniqueness with scheduled queries that raise alerts when COUNT(id) ≠ COUNT(DISTINCT id).

How is incremental sync handled?

Add an updated_at column to each table and schedule nightly UNLOADs filtering on last export timestamp.Use BigQuery MERGE to upsert.

bq query """
MERGE ecommerce.customers T
USING staging.customers S
ON T.id = S.id
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT ROW"""

When should I cut over?

After full reload, run dual-writes for 24 hours, compare row counts, and validate critical queries. Switch applications once parity is confirmed.

Best practices

• Export in Parquet for type fidelity. • Use parallel UNLOAD to speed extraction. • Load into staging tables first, then promote. • Automate validation with COUNT(*) and MIN/MAX timestamps.

.

Why How to Migrate from Redshift to BigQuery in PostgreSQL is important

How to Migrate from Redshift to BigQuery in PostgreSQL Example Usage


-- Full workflow for Orders table
-- Redshift side
UNLOAD ('SELECT * FROM orders')
TO 's3://my-bucket/migration/orders_'
FORMAT AS PARQUET PARALLEL ON;

-- Terminal
gsutil rsync -r s3://my-bucket/migration gs://my-gcs-bucket/migration

-- BigQuery side
bq load --source_format=PARQUET ecommerce.orders \
        gs://my-gcs-bucket/migration/orders_*;

How to Migrate from Redshift to BigQuery in PostgreSQL Syntax


-- 1. Export from Redshift to S3 (Customers example)
UNLOAD ('SELECT * FROM customers')
TO 's3://my-bucket/migration/customers_'
FORMAT AS PARQUET PARALLEL ON;

-- 2. Copy S3 → GCS
$ gsutil rsync -r s3://my-bucket/migration gs://my-gcs-bucket/migration

-- 3. Load into BigQuery
$ bq load --source_format=PARQUET ecommerce.customers \
         gs://my-gcs-bucket/migration/customers_*

-- 4. Validate
SELECT COUNT(*) FROM `ecommerce.customers`;

Common Mistakes

Frequently Asked Questions (FAQs)

Is downtime required?

No. Use incremental UNLOADs and dual-writes to keep both warehouses in sync until cutover.

Can I automate the pipeline?

Yes. Orchestrate UNLOAD, gsutil, and bq load steps with Airflow or Cloud Composer for fully managed scheduling.

What about stored procedures?

Rewrite Redshift PL/pgSQL procedures to BigQuery scripting or Dataform. Automated translation tools are limited.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.