Migration Guide: From Redshift, BigQuery & Legacy Warehouses
Learn how to migrate from Redshift, BigQuery, or legacy warehouses to Snowflake.
20+ years shipping high-throughput database systems. Notes here come from systems that actually shipped.
- ✓Basic knowledge of SQL and data warehousing concepts.
- ✓Access to source warehouse and Snowflake account.
- ✓Understanding of cloud storage (S3, GCS, Azure Blob).
- ✓Familiarity with ETL/ELT processes.
Migrating to Snowflake involves assessing your source warehouse, converting DDL and DML, handling data types, optimizing storage, and testing performance. Key differences include Snowflake's separation of compute and storage, automatic clustering, and zero-copy cloning.
Think of migrating to Snowflake like moving from an old apartment (your current warehouse) to a new, modern one. You need to pack your furniture (data), label boxes (convert schemas), and maybe change some items (data types). Snowflake is like a smart building where you can add or remove rooms (compute) as needed, and you never have to worry about cleaning (automatic optimization).
Migrating to Snowflake from Amazon Redshift, Google BigQuery, or a legacy data warehouse is a strategic move for many organizations seeking better scalability, performance, and cost management. Snowflake's unique architecture—separating storage and compute, automatic scaling, and near-zero maintenance—makes it an attractive target. However, migration is not trivial. Differences in SQL syntax, data types, partitioning, and performance optimization require careful planning. This guide provides a practical, step-by-step approach to migrating your data warehouse to Snowflake. We'll cover schema conversion, data transfer, query adaptation, and common pitfalls. Whether you're moving from a traditional on-premise warehouse or a cloud-based solution, you'll find actionable advice and real-world examples. By the end, you'll be equipped to execute a smooth migration with minimal downtime.
1. Assessing Your Source Warehouse
Before migrating, thoroughly assess your current data warehouse. Identify all databases, schemas, tables, views, stored procedures, and user-defined functions. Document data types, indexes, partitioning schemes, and any proprietary features. For Redshift, note sort keys and distribution styles. For BigQuery, note clustering and partitioning. For legacy warehouses, capture any custom SQL dialects. This assessment will guide your conversion strategy. Create a migration plan that includes a timeline, resource allocation, and rollback procedures. Use Snowflake's Migration Assessment Tool if available.
2. Converting DDL and Data Types
Snowflake uses a different SQL dialect and data type system. Map source types to Snowflake equivalents: Redshift's BIGINT to NUMBER(38,0), TIMESTAMP to TIMESTAMP_NTZ, VARCHAR to VARCHAR. BigQuery's ARRAY<STRUCT> to VARIANT, GEOGRAPHY to GEOGRAPHY. Legacy types like MONEY to NUMBER(19,4). Use Snowflake's CONVERT function or manual CAST. For DDL, replace Redshift's DISTKEY and SORTKEY with Snowflake's clustering keys. BigQuery's partitioning becomes Snowflake's automatic clustering. Legacy indexes are not needed; Snowflake uses automatic micro-partitioning. Example conversion: Redshift CREATE TABLE with DISTKEY and SORTKEY becomes Snowflake CREATE TABLE with CLUSTER BY.
3. Data Transfer Strategies
Choose a data transfer method based on volume and latency requirements. Options: 1) COPY INTO from cloud storage (S3, GCS, Azure Blob) using external stages. 2) Snowpipe for continuous ingestion. 3) Third-party ETL tools (Fivetran, Matillion). 4) Custom scripts using Snowflake's Python connector. For large datasets, use COPY INTO with compression (gzip, snappy). Use VALIDATION_MODE to catch errors before loading. Example: unload from Redshift to S3 as CSV, then COPY into Snowflake. For BigQuery, export to GCS as Parquet. For legacy, use ODBC/JDBC bulk export.
4. Query Adaptation and Optimization
Rewrite queries to leverage Snowflake's features. Replace Redshift's window functions with Snowflake's (similar but check syntax). BigQuery's UNNEST becomes LATERAL FLATTEN. Legacy SQL might need CTEs or subqueries. Optimize by using clustering keys on frequently filtered columns, materialized views for aggregations, and result caching. Avoid anti-patterns like SELECT * in production. Use query profiles to identify bottlenecks. Example: convert a Redshift query with DISTKEY join to Snowflake without explicit distribution.
5. Handling Stored Procedures and UDFs
Migrate stored procedures and UDFs to Snowflake's JavaScript or SQL-based procedures. Redshift's PL/pgSQL can be converted to Snowflake's JavaScript stored procedures. BigQuery's UDFs in SQL or JavaScript can be ported directly. Legacy procedures may need significant rewriting. Use Snowflake's CREATE PROCEDURE with LANGUAGE JAVASCRIPT. For simple logic, use SQL UDFs. Test each procedure with sample data. Example: convert a Redshift procedure to Snowflake.
6. Testing and Validation
After migration, validate data integrity and performance. Compare row counts, checksums, and sample records between source and target. Use MINUS to find differences. Run a subset of production queries and compare results. Test with concurrent users to assess warehouse scaling. Monitor Snowflake's query history and account usage. Create a rollback plan if issues arise. Example: validate using MINUS.
7. Post-Migration Optimization
After migration, optimize Snowflake for cost and performance. Set up resource monitors to control costs. Enable auto-suspend for warehouses. Use automatic clustering and materialized views. Implement time travel retention as needed. Monitor with Snowflake's built-in tools. Consider using Snowflake's search optimization service for point lookup queries. Example: create a resource monitor.
The Midnight Migration Meltdown
- Always map source data types to target types before migration.
- Test with a subset of data first.
- Use Snowflake's COPY INTO with schema detection for complex types.
- Document all type conversions for future reference.
- Plan for rollback in case of issues.
COPY INTO table FROM @stage VALIDATION_MODE = 'RETURN_ERRORS';SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| File | Command / Code | Purpose |
|---|---|---|
| assess_source.sql | SELECT pg_catalog.pg_get_viewdef('schema.table_name', true); | 1. Assessing Your Source Warehouse |
| convert_ddl.sql | CREATE TABLE orders ( | 2. Converting DDL and Data Types |
| data_transfer.sql | CREATE OR REPLACE STAGE my_stage | 3. Data Transfer Strategies |
| query_adaptation.sql | SELECT o.order_id, c.name | 4. Query Adaptation and Optimization |
| stored_procedure.sql | CREATE OR REPLACE PROCEDURE update_orders() | 5. Handling Stored Procedures and UDFs |
| validation.sql | SELECT COUNT(*) FROM source_table; | 6. Testing and Validation |
| optimization.sql | CREATE OR REPLACE RESOURCE MONITOR my_monitor | 7. Post-Migration Optimization |
Key takeaways
Common mistakes to avoid
4 patternsNot mapping data types correctly
Ignoring query performance differences
Forgetting to set up resource monitors
Migrating all data at once without validation
Interview Questions on This Topic
What are the key differences between Snowflake and Redshift that affect migration?
Frequently Asked Questions
20+ years shipping high-throughput database systems. Notes here come from systems that actually shipped.
That's Snowflake. Mark it forged?
3 min read · try the examples if you haven't