# Migrate from Snowflake
> Plan and run a migration from Snowflake to MotherDuck, from inventorying what you run today to validating and cutting over one workload at a time.
A warehouse migration can be broken down into a series of smaller steps: inventory what Snowflake runs, split it into workloads that don't depend on each other, then move one workload at a time and validate it before the next. This guide covers that process. For the mechanics of copying a single table, see the [Snowflake integration page](/integrations/databases/snowflake/).

You'll know a workload is done when its consumers read from MotherDuck, its pipeline writes to MotherDuck on a schedule, and nothing in Snowflake has to run for it to stay current.

:::info Prerequisites

- A [MotherDuck organization](/key-tasks/managing-organizations/), with the region and plan already chosen.
- A Snowflake role that can read the `SNOWFLAKE.ACCOUNT_USAGE` schema, and a running warehouse. By default only `ACCOUNTADMIN` can read `ACCOUNT_USAGE`, so grant the `OBJECT_VIEWER` and `USAGE_VIEWER` database roles for the catalog and spend history, plus `GOVERNANCE_VIEWER` for usage information and access policies.

:::

## What to move

A data platform has a lot of moving parts. The sections below go through all of them, but you probably don't need every one, so treat this as the raw material for your own migration plan rather than a checklist to complete. The areas to account for:

- **Ingestion**: the triggers, connections, and service accounts that get source data into the warehouse in the first place. List the tools that write *directly* to Snowflake early. Some tools like Segment, Stitch, and Braze, have native Snowflake integrations, but lack MotherDuck integrations; however, nearly all of them can write Parquet or JSON to a data lake instead. MotherDuck can read from these data lake destinations, by-passing the need for a direct integration.
- **Transformations and metrics**: the dbt models, stored procedures, and other compute that turn raw data into something your users or downstream tools consume.
- **Data quality checks**: whatever you monitor for source freshness, accuracy, and completeness.
- **Archiving, retention, and backups**: look for processes that perform backups or expire data for regulatory reasons.
- **Monitoring and alerting**: how the platform tells you about data issues, billing, and usage, wherever you happen to be.
- **Governance**: access control and ownership, for both people and machines. [MotherDuck does not support masking policies and row-access policies](#governance-features-without-an-equivalent), so you will need to design a replacement before cutover.
- **Reverse ETL and signals**: the tools that consume the data once it's modelled, for marketing activation or connected data apps.
- **Data apps**: anything interactive connected to, or hosted on, the platform.

## Inventory what Snowflake runs

The fastest path is the [MotherDuck migration assessment collector](https://github.com/motherduckdb/md-migration-assessment), a Python CLI that inventories a Snowflake account into a local DuckDB file: catalog, feature usage, workload profile, and spend, with provenance for each number. It runs locally and uploads nothing unless you ask it to. It's in Public Preview, so pin a release rather than tracking `main`.

The migration assessment collector runs queries like the following:

**What objects exist, and how big are they?**

```sql
SELECT
    table_catalog,
    table_schema,
    table_name,
    table_type,
    row_count,
    bytes,
    last_altered
FROM snowflake.account_usage.tables
WHERE deleted IS NULL
ORDER BY bytes DESC;
```

**Which of them does anyone actually read?**

```sql
SELECT
    accessed.value:objectName::string AS object_name,
    COUNT(DISTINCT query_id) AS query_count,
    MAX(query_start_time) AS last_read
FROM snowflake.account_usage.access_history,
    LATERAL FLATTEN(input => base_objects_accessed) AS accessed
WHERE query_start_time >= DATEADD(day, -90, CURRENT_TIMESTAMP())
GROUP BY ALL
ORDER BY query_count DESC;
```

`ACCESS_HISTORY` needs Enterprise Edition or higher. Without it, fall back to pattern matching table names against `query_text` in `SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY`, which is coarser but still separates live tables from dead ones.

**Who and what connects?**

```sql
SELECT
    user_name,
    role_name,
    warehouse_name,
    COUNT(*) AS queries,
    MAX(start_time) AS last_query
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD(day, -90, CURRENT_TIMESTAMP())
GROUP BY ALL
ORDER BY queries DESC;
```

Service accounts show up here next to people. Each one is a connection you'll have to repoint later, so treat this list as your cutover checklist.

**What shape is the compute?**

```sql
SELECT
    warehouse_name,
    DATE_TRUNC('hour', start_time) AS hour,
    SUM(credits_used) AS credits
FROM snowflake.account_usage.warehouse_metering_history
WHERE start_time >= DATEADD(day, -30, CURRENT_TIMESTAMP())
GROUP BY ALL
ORDER BY hour;
```

A warehouse that burns credits in two spikes a day is a batch pipeline. One that burns them evenly through business hours is serving dashboards. The two need different Duckling sizing on the other side, so it's worth knowing which is which before you size anything.

:::note
`ACCOUNT_USAGE` views lag live activity by 45 minutes to 3 hours and retain one year of history. Pull them once at the start of the migration and refresh before cutover rather than reading them live.
:::

:::warning
A query against `INFORMATION_SCHEMA.TABLES` without a running warehouse returns zero tables and no error. If you receive an empty result, check the warehouse before you conclude a database is unused.
:::

To automate the catalog side of this, the [Snowflake ingest Flight recipe](/cookbook/flight-snowflake-ingest/) enumerates source tables into an editable MotherDuck control table with a `selected` flag, then copies the ones you flag.

## Sort the inventory into four buckets

With those observations you can decide, for every object, which of these it is.

**What needs to be copied?** When you replicate user data from a Postgres database that's frequently updated but keeps no history, you might be storing that history in the warehouse, often as a slowly changing dimension (SCD) type II. The warehouse is the system of record for it: drop the table and the history goes with it.

**What can be rebuilt from source?** Web analytics data stored per day in your data lake can be read directly from that data lake in MotherDuck. You apply the same transformations and rebuild the full pipeline from the source. That workflow is *idempotent*: running it multiple times, from whichever warehouse, produces the same result each time. Rebuilding is better than copying where you have the choice, because it proves the new pipeline works instead of asking you to trust a one-time transfer.

**What can be queried in place?** You may have data in S3, GCS, or an Iceberg catalog doesn't need loading at all. MotherDuck can read it where it sits, so you can defer the decision about whether a table is hot enough to be worth storing.

**What can be left behind?** Building a data pipeline generates a lot of development data that can be safely discarded, and there are always tables whose purpose can no longer be identified. Use the query history and access history tables to determine what falls in this category.

Record the answer as a column on your inventory table. Everything after this point works off that column.

## Group what's left into independent workloads

Two sets of models belong to the same workload when anything downstream joins their data together. Until that join exists, they can move on separate days without coordination.

```mermaid
flowchart LR
    S3[("Event files<br/>in S3")]:::db
    PG[("Users in<br/>Postgres")]:::db

    subgraph B["Workload B: two sources, one consumer, moves as one unit"]
        MA["Session models"]
        MB["Account history models"]
        DASH{{"Revenue dashboard"}}:::green
    end

    API[("Weather<br/>API")]:::db

    subgraph A["Workload A: moves on its own"]
        MC["Forecast models"]
        APP{{"Delivery data app"}}:::green
    end

    S3 --> MA
    PG --> MB
    MA --> DASH
    MB --> DASH
    API --> MC
    MC --> APP
```

Shared tables are what make this hard. An `orders` table referenced by nine downstream models pulls all nine into the same workload, which can make the first migration much larger than you wanted. Two ways out: move the shared table first and let both warehouses read their own copy during the overlap, or accept the larger workload and move it as one.

Order the workloads by risk rather than by size. The first one to move should have a small number of consumers, a tolerant audience, and a source you can replay, because it's the one that will teach you what your migration actually costs.

## Set up the infrastructure for migration

Before you migrate individual workloads, get the shared infrastructure in place: everything needed to run the workloads and to provision more of them later. We recommend a DevOps approach with an infrastructure-as-code tool, which keeps your environments identical to each other. The [MotherDuck Terraform provider](/integrations/dev-tools/terraform/) manages databases, schemas, shares, roles, secrets, and service accounts as code, and works with OpenTofu too.

To get started you'll need:

- Credentials for provisioning in MotherDuck, and in your object storage (S3, GCS, and so on) where you use it.
- Git repositories, for example for a new dbt project or for Python transformation pipelines.
- Access to an existing ingestion system such as MotherDuck Flights, dltHub, Fivetran, or similar.

Then set up the MotherDuck side, which is shared across every workload:

| Set up | Why it comes first |
|---|---|
| A service account per pipeline stage, each owning one database | Each MotherDuck database has a single write user, and each account gets its own compute. One account per stage isolates both. See [designing your warehouse](/key-tasks/data-warehousing/#designing-your-motherduck-data-warehouse). |
| Dev, staging, and production accounts | Transformations read production data in every phase and write to isolated outputs. [Environment management](/key-tasks/data-warehousing/environment-management/) covers the pattern. |
| Secrets for object storage and source systems, created by the account that uses them | Secrets are scoped to the account that creates them, so one created under your personal account is invisible to the pipeline. |

### Three habits to unlearn

Snowflake and MotherDuck disagree about what a database *is*, and all three of the mistakes below come from carrying the Snowflake model across unchanged.

**A database belongs to whoever created it, not to the account.** In Snowflake, a database sits in the account and anyone whose role grants access can see it. In MotherDuck it belongs to the user or service account that created it, and the rest of the organization can't see it at all until you share it. A colleague querying an unshared database gets `Catalog Error: schema "x" does not exist`, which reads like a typo rather than a permissions problem. Publish it with a [share](/key-tasks/sharing-data/):

```sql
CREATE SHARE IF NOT EXISTS models FROM models (ACCESS RESTRICTED);
GRANT READ ON SHARE models TO ROLE explorer;
```

Granting to `explorer` reaches every preset role, because they're concentric. Grant to a [custom role](/concepts/roles-and-access-control/#custom-roles) instead when only one team should see it.

**Ownership can't be transferred, so create production objects with a service account from the start.** A database, Dive, or Flight created under a personal account stays with that account. When the person who built that pipeline leaves, the objects are stranded. Service accounts prevent this situation.

**Databases are cheap, so make more of them.** Each MotherDuck database takes one writer at a time. In Snowflake you'd absorb write concurrency by sizing a warehouse up or running a multi-cluster one; here you absorb it by splitting across databases. A pipeline fanning 20 concurrent writers at a single database (Dagster, Airflow, and Kinesis consumers all do this) needs a database per pipeline, or writes serialized into one. For the same reason, dev and production dbt targets must never point at the same database: Snowflake's separate databases or warehouses usually prevent the collision for you, and MotherDuck doesn't.

## Move the workload

Decide how much you're changing on the way across before you open the first file.

**Lift and shift** moves the logic as-is and changes only what's needed to make it run. It's fast, and validation is unambiguous: the correct result is whatever Snowflake produced. It also carries every piece of accumulated debt across with it.

**Greenfield** goes back to the stakeholders, re-gathers requirements, and rebuilds. No debt, no dialect translation, but you depend on other people's calendars and you've lost the ability to validate against the old output.

Most migrations end up in between, usually under time pressure. This is the business equivalent of moving house: when you pack something in a box and think "I haven't touched this in five years", you throw it out there and then, rather than believing you'll go through all your belongings one by one once you're settled in the new place. You won't.

So instead of packing everything and moving the boxes, apply a level of cleanup on the way. Delete what the inventory says is unused. Add comments where the SQL made you stop and think, and find the stakeholder who can explain any logic you don't understand. Where you spot a bigger improvement, write a note so you can come back to it after the migration rather than starting it mid-move.

:::tip
Budget time after the port, not just for it. A direct translation of Snowflake SQL runs on MotherDuck, but it may not run efficiently. See the guide on [tuning a migrated Snowflake workload](/key-tasks/data-warehousing/migrating-from-snowflake/tuning-a-migrated-snowflake-workload/) for specific workload patterns that need optimization.
:::

With that settled, move in dependency order:

1. **Land the raw data.** Point ingestion at MotherDuck, or copy the tables you bucketed as "copy". Keep Snowflake ingestion running in parallel.
2. **Port the transformations.** Repoint the dbt or SQLMesh project at a MotherDuck target and work through the dialect differences below. Transformations can also [run from a Flight](/key-tasks/flights/run-dbt-transformations-from-a-flight/) if you'd rather not keep a separate runner.
3. **Rebuild the quality checks.** Source freshness tests, row-count assertions, and null checks move with the models they guard. Don't defer them: they're what tells you the next step went wrong.
4. **Repoint the consumers.** Dashboards, reverse ETL jobs, and data apps connect as service accounts with read access. Change them one at a time.

## Translate the Snowflake-specific pieces

| Snowflake | In MotherDuck |
|---|---|
| Unquoted identifiers stored uppercase | DuckDB keeps the case it receives and resolves lookups case-insensitively, so queries keep working. Rename columns during the load if you want lowercase names. |
| `NUMBER(38,0)` | Snowflake's default `NUMBER` is `NUMBER(38,0)`, and transpilers carry it across as `DECIMAL(38,0)`, which DuckDB stores as a 128-bit integer: bigger on disk and slower to compute, hash, and join on. Cast integer-like columns to `BIGINT` (or the equivalent `DECIMAL(18,0)`) and keep 38 digits only where the values need them, which is almost nowhere. Go looking for this, it won't announce itself. |
| `TIMESTAMP_NTZ`, `TIMESTAMP_LTZ`, `TIMESTAMP_TZ` | DuckDB has two types, `TIMESTAMP` and `TIMESTAMPTZ`, and MotherDuck has no account-wide default timezone. In Snowflake an admin can change the account `TIMEZONE` parameter, which silently moves what `TIMESTAMP_LTZ` columns and `CURRENT_TIMESTAMP` mean for everyone, so a model can be correct against one account setting and wrong against another without its SQL changing. Pin the timezone explicitly in the models themselves rather than inheriting it. |
| `VARIANT`, `OBJECT`, `ARRAY` | Arrive as JSON strings. Cast to `JSON`, `STRUCT`, or `LIST` to query them natively. |
| Clustering keys | DuckDB has no clustering. Sorting on insert does the same job, because row-group statistics let the scan skip ranges that can't match. See [sort tables by common filter columns](/key-tasks/query-performance/#sort-tables-by-common-filter-columns). |
| Time Travel | [Database snapshots](/concepts/snapshots/) and [UNDROP](/concepts/data-recovery/) cover point-in-time restore. Retention is set by plan rather than per query, and only the Business plan can change `snapshot_retention_days`, so check the window you land on matches what your Snowflake Time Travel settings assumed. |
| Streams and Tasks | A [Flight](/concepts/flights/) on a cron schedule, or an external orchestrator for pipelines with cross-system dependencies. |
| Stored procedures and Snowpark | Python in a [Flight](/key-tasks/flights/), which runs any PyPI package next to your data. |
| Reader accounts | [Shares](/key-tasks/sharing-data/), which give read-only access to a database and work for recipients outside your organization. A MotherDuck share reaches MotherDuck users, though, so a recipient who needs to consume the data from Snowflake itself needs a file-based handoff instead. |
| Streamlit in Snowflake | [Dives](/key-tasks/dives/), React and SQL apps that live in the workspace alongside your data. |
| `GRANT SELECT ON TABLE ... TO ROLE` | Create a Share with an include pattern for the audience, then `GRANT READ ON SHARE ... TO ROLE`. See [roles and access control](/concepts/roles-and-access-control/). |
| Marketplace datasets and inbound data shares | No equivalent. Anything you consume through Snowflake's sharing graph has to be re-sourced from the provider directly, or read from a small Snowflake account you keep alive for that feed. Inventory these during assessment: they're nobody's model and so they're easy to miss until something breaks. |
| Warehouse sizing | Compute is per account, not per cluster. Size each service account's [Duckling](/about-motherduck/billing/duckling-sizes/) for the job it runs, and use [read scaling](/key-tasks/authenticating-and-connecting-to-motherduck/read-scaling/) for concurrent dashboard traffic. |

### Governance features without an equivalent

Four Snowflake governance features have no MotherDuck counterpart: **row access policies**, **column masking policies**, **per-object and per-column grants**, and **network policies**.

Access in MotherDuck is granted per Share rather than per object. [Table-level security](/key-tasks/sharing-data/table-level-security/) narrows a Share to named tables and views with an include pattern, on the Business and Enterprise plans, so the usual replacement for a row or column policy is a shape change rather than a setting: publish a Share per audience from a source that already excludes what that audience shouldn't see, or maintain a masked copy of the source database and share that. [Environment management](/key-tasks/data-warehousing/environment-management/) describes the masked-copy pattern for regulated data.

Row-level security and column-level permissions on Shares are on our roadmap, so check where they've got to before you design around their absence.

:::warning
Surface this during assessment, not at cutover. Where masking or row access policies back a compliance commitment, the replacement is a data-modelling change with a review attached, and that's weeks of lead time rather than a configuration change on the day.
:::

## Validate against Snowflake before you cut over

Run the same aggregate on both sides, per table, and compare:

```sql
SELECT
    COUNT(*) AS row_count,
    COUNT(DISTINCT order_id) AS distinct_keys,
    SUM(amount) AS amount_total,
    MIN(ordered_at) AS first_row,
    MAX(ordered_at) AS last_row
FROM analytics.public.orders;
```

:::warning
Hash-based checksums don't carry across engines. Snowflake's `HASH()` and DuckDB's `hash()` are different functions, so the two sides disagree on `SUM(HASH(col))` even when the data is identical. Compare counts, distinct counts, numeric sums, and min/max of keys and timestamps.
:::

Where the aggregates disagree, load the Snowflake copy into a staging table in MotherDuck and anti-join to find the rows:

```sql
CREATE TABLE staging.orders_snowflake AS
SELECT * FROM read_parquet('s3://<bucket>/validation/orders/*.parquet');

-- Keys Snowflake has that MotherDuck doesn't. Swap the two sides for the reverse.
SELECT order_id
FROM staging.orders_snowflake
EXCEPT
SELECT order_id
FROM marts.main.orders;
```

Three causes account for most mismatches: a timezone difference at a date boundary, a rounding difference from the `NUMBER` to `DECIMAL` mapping, and a load that ran while the source was still changing. Check the source watermark on both sides before you go looking for a logic bug.

Also compare at the level your users care about. A dashboard whose numbers match to the cent is more convincing evidence than a table-level row count, and it's the comparison someone will make anyway.

## Cut over and decommission

1. **Freeze the Snowflake side of the workload.** Stop the tasks that write to it so the two warehouses can't diverge while you switch.
2. **Repoint the consumers** and leave the Snowflake objects in place, readable.
3. **Run read-only in parallel** for a window you agree in advance, usually one full reporting cycle. This is what catches a month-end model nobody tested.
4. **Suspend the warehouse** rather than dropping it. Spend stops, and you can resume if something surfaces.
5. **Record the date you stopped writing.** It's the point any later "the numbers changed" question resolves against.

Drop the Snowflake objects only after the parallel window closes and the final `ACCOUNT_USAGE` read shows nothing querying them.

## Rethink what Snowflake shaped

Once a workload runs on MotherDuck, some of its shape was dictated by Snowflake rather than by the problem:

- PySpark jobs that existed because the transformation didn't fit in SQL often do fit, or fit in a Flight.
- A dbt Cloud subscription that only runs scheduled builds can become a [scheduled Flight](/key-tasks/flights/scheduling-and-runs/).
- Streamlit apps written to sit next to the data become [Dives](/key-tasks/dives/), which you generate from a prompt rather than hand-build.
- Warehouse right-sizing becomes per-account Duckling sizing, so a heavy backfill no longer competes with the dashboards.

Hold these until after the workload is validated. Changing the logic and the platform in the same step means a mismatch has two possible causes.

## Related

- [Tuning a migrated Snowflake workload](/key-tasks/data-warehousing/migrating-from-snowflake/tuning-a-migrated-snowflake-workload/) for what to fix once the SQL runs
- [Snowflake integration](/integrations/databases/snowflake/) for the table copy mechanics
- [Ingest Snowflake tables into MotherDuck from a Flight](/cookbook/flight-snowflake-ingest/)
- [Data warehousing guide](/key-tasks/data-warehousing/)
- [Environment management](/key-tasks/data-warehousing/environment-management/)
- [Data loading patterns](/key-tasks/loading-data-into-motherduck/loading-patterns/)


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fkey-tasks%2Fdata-warehousing%2Fmigrating-from-snowflake%2F&page_title=Migrate%20from%20Snowflake&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
