Snowflake Data Cloud
Module 04 • Signature Features

Time Travel, Dynamic Tables & Stages

These three features come up in almost every Snowflake interview. Time Travel is about how you undo mistakes. Dynamic Tables are about how you build pipelines without orchestration code. Stages are about how data gets in at all.

~75 min Recovery-window simulator Hard Time Travel Q&A
01

Time Travel

Query, clone or restore data as it was at any point inside the retention period.

How it works: micro-partitions are immutable. When you change data, the old micro-partitions are not deleted. They are kept for DATA_RETENTION_TIME_IN_DAYS. Time Travel is simply reading the set of micro-partitions that was current at an earlier moment, so it costs nothing extra in compute. You only pay for the storage of the old versions.

Retention rules

ObjectStandard editionEnterprise+Fail-safe after
Permanent table / schema / database0 or 1 day (default 1)0–90 days (default 1)7 days
Transient table0 or 1 day0 or 1 dayNone
Temporary table0 or 1 day (ends with session)0 or 1 dayNone

Retention can be set on the account, database, schema or table. The most specific setting wins. ACCOUNTADMIN can also set MIN_DATA_RETENTION_TIME_IN_DAYS at account level as a floor that nobody can go below.

-- Set retention
ALTER TABLE orders SET DATA_RETENTION_TIME_IN_DAYS = 30;

-- Query the past: by timestamp, by relative offset (seconds), or by statement
SELECT * FROM orders AT (TIMESTAMP => '2026-10-15 09:00:00'::TIMESTAMP_LTZ);
SELECT * FROM orders AT (OFFSET => -60*60);                 -- 1 hour ago
SELECT * FROM orders BEFORE (STATEMENT => '01b2c3d4-0000-1234-0000-0001a2b3c4d5');

-- Compare now vs yesterday to find what changed
SELECT * FROM orders AT (OFFSET => -86400)
MINUS
SELECT * FROM orders;

-- Restore by cloning a point in time (instant, zero-copy)
CREATE TABLE orders_fix CLONE orders AT (OFFSET => -3600);

-- Bring back dropped objects
UNDROP TABLE orders;
SHOW TABLES HISTORY LIKE 'ORDERS';   -- dropped versions show a dropped_on value

-- Row-level change feed over a window (requires change tracking)
ALTER TABLE orders SET CHANGE_TRACKING = TRUE;
SELECT * FROM orders
  CHANGES (INFORMATION => DEFAULT)
  AT (TIMESTAMP => DATEADD(hour, -2, CURRENT_TIMESTAMP()));

AT vs BEFORE: AT includes changes made by a statement at that exact point. BEFORE(STATEMENT => id) shows the data right before that statement ran. That makes it the precise tool for undoing one bad query.

Recovery-window simulator
A mistake happened some days ago. Can you still fix it yourself, do you need Snowflake Support, or is the data gone?
Edition
Table type
Max allowed here: 90
What happened
Timeline from the mistake (left) to today (right edge = –)
Time Travel (self-service) Fail-safe (Support only) purged
-- adjust the controls
02

Time Travel: the hard questions

These edge cases separate people who have read the docs from people who have recovered production data.
03

Dynamic Tables

Write the SELECT you want the table to equal. Snowflake keeps it within a freshness target.

A dynamic table is defined by a query and a target lag, the maximum acceptable staleness. Snowflake works out when to refresh, refreshes incrementally (processing only changed rows) when it can, and orders refreshes across a chain of dynamic tables. No streams, tasks, schedules or MERGE statements to write.

-- Bronze -> Silver: clean and deduplicate
CREATE OR REPLACE DYNAMIC TABLE silver.orders
  TARGET_LAG   = DOWNSTREAM          -- refresh only when something downstream needs it
  WAREHOUSE    = transform_wh
  REFRESH_MODE = AUTO                -- INCREMENTAL if possible, otherwise FULL
AS
SELECT order_id, customer_id, amount, status, updated_at
FROM raw.orders
QUALIFY ROW_NUMBER() OVER (PARTITION BY order_id ORDER BY updated_at DESC) = 1;

-- Silver -> Gold: business aggregate, must be at most 15 minutes stale
CREATE OR REPLACE DYNAMIC TABLE gold.daily_revenue
  TARGET_LAG = '15 minutes'
  WAREHOUSE  = transform_wh
AS
SELECT DATE_TRUNC('day', o.updated_at) AS day, c.region, SUM(o.amount) AS revenue
FROM silver.orders o
JOIN silver.customers c USING (customer_id)
WHERE o.status = 'COMPLETE'
GROUP BY 1, 2;

-- Operate it
ALTER DYNAMIC TABLE gold.daily_revenue REFRESH;           -- refresh now
ALTER DYNAMIC TABLE gold.daily_revenue SUSPEND;           -- stop refreshing
ALTER DYNAMIC TABLE gold.daily_revenue SET TARGET_LAG = '1 hour';
SHOW DYNAMIC TABLES LIKE 'DAILY%';                        -- see refresh_mode + reason

SELECT name, state, refresh_action, refresh_trigger,
       refresh_start_time, refresh_end_time
FROM TABLE(information_schema.dynamic_table_refresh_history())
ORDER BY refresh_start_time DESC LIMIT 20;
Dynamic tableStreams + TasksMaterialized view
StyleDeclarative (one SELECT)Imperative (you write MERGE / procedures)Declarative
Joins, unions, window functionsYesAnythingSingle table only
FreshnessTarget lag (minimum 1 minute)Your schedule or triggerAlways current at query time
ComputeYour warehouseYour warehouse or serverless tasksServerless
Procedural logic, external calls, custom error handlingNoYesNo
Best forSQL transformation pipelines (bronze → silver → gold)Complex CDC, SCD2 with custom rules, side effectsSpeeding up one repeated aggregate

Things that trip people up

  • Target lag is a target, not a guarantee. Slow refreshes or an undersized warehouse lead to missed lag.
  • Non-deterministic functions such as CURRENT_TIMESTAMP() block incremental refresh. In AUTO mode the table silently becomes FULL refresh, which can be expensive.
  • You can't INSERT/UPDATE a dynamic table directly. Its content is defined by the query.
  • Incremental refresh needs change tracking on the base tables. Snowflake enables it if the owner has the privilege.

Cost levers

  • Longer lag means fewer refreshes and fewer warehouse wake-ups.
  • Use DOWNSTREAM for intermediate tables so they refresh only when the final table needs them.
  • Give dynamic tables their own warehouse with AUTO_SUSPEND = 60.
  • Check refresh_mode_reason in SHOW DYNAMIC TABLES to confirm you got INCREMENTAL.
04

Stage integrations and loads

The step-by-step AWS and Azure setup is in Module 03. This section covers the concepts and options you need in production.

The four kinds of stage

StageReferenceCreated byUse it for
User stage@~Automatic, one per userPersonal files only you load
Table stage@%ordersAutomatic, one per tableFiles that only ever load into that table. No file format object, no grants to others.
Named internal stage@raw.landingCREATE STAGEShared landing area inside Snowflake. Upload with PUT or the Snowsight UI.
Named external stage@raw.s3_ordersCREATE STAGE … URL = … STORAGE_INTEGRATION = …Files already in S3, Azure or GCS. This is the production default.

Why storage integrations and not keys? A stage can be created with CREDENTIALS = (AWS_KEY_ID=… AWS_SECRET_KEY=…), but then secrets live in SQL text and query history and need manual rotation. An integration delegates trust to an IAM role or Azure service principal. STORAGE_ALLOWED_LOCATIONS limits which paths any stage built on it can reach. Many security teams require REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION = TRUE at account level.

COPY INTO options you'll actually use

OptionWhat it does
FILE_FORMATCSV, JSON, PARQUET, AVRO, ORC or XML, plus parsing options (delimiter, header skip, null handling).
PATTERN / FILESRegex or explicit list to pick a subset of files in the stage path.
ON_ERRORABORT_STATEMENT (COPY default), CONTINUE, SKIP_FILE (Snowpipe default), SKIP_FILE_<n> or SKIP_FILE_<n>%.
VALIDATION_MODERETURN_ERRORS or RETURN_<n>_ROWS: test without loading.
MATCH_BY_COLUMN_NAMEMap Parquet/Avro/ORC/JSON (and CSV with header) fields to columns by name, not position.
FORCEReload files even if load metadata says they were already loaded. Risk of duplicates.
PURGEDelete files from the stage after a successful load. Needs delete permission on external storage.
SIZE_LIMITStop picking new files after roughly this many bytes in one COPY.
COPY INTO raw.orders (order_id, amount, order_ts, src_file, loaded_at)
FROM (
  SELECT $1:order_id::NUMBER,
         $1:amount::NUMBER(12,2),
         $1:ts::TIMESTAMP_NTZ,
         METADATA$FILENAME,
         CURRENT_TIMESTAMP()
  FROM @raw.s3_orders
)
FILE_FORMAT = (TYPE = JSON)
PATTERN = '.*2026/10/.*[.]json[.]gz'
ON_ERROR = 'SKIP_FILE';

-- Unload (export) works the other way round
COPY INTO @raw.s3_exports/daily_revenue/
FROM gold.daily_revenue
FILE_FORMAT = (TYPE = PARQUET)
HEADER = TRUE
OVERWRITE = TRUE;

COPY vs Snowpipe vs Snowpipe Streaming

Bulk COPYSnowpipeSnowpipe Streaming
TriggerYou run it (task, Airflow, dbt)Cloud event notification or REST call per fileSDK / Kafka connector pushes rows
ComputeYour warehouseServerlessServerless
LatencyYour scheduleTypically about a minute after the file landsSeconds
Load historyLoad metadata kept 64 daysPipe metadata kept 14 daysOffset tokens per channel
Best forLarge nightly batchesFiles trickling in all dayEvent streams with no files at all

Troubleshooting loads

-- What did COPY / Snowpipe do with each file in the last day?
SELECT file_name, status, row_count, row_parsed, first_error_message, last_load_time
FROM TABLE(information_schema.copy_history(
       TABLE_NAME => 'RAW.ORDERS',
       START_TIME => DATEADD(hour, -24, CURRENT_TIMESTAMP())))
ORDER BY last_load_time DESC;

-- Rows rejected by the last COPY job ('_last' = most recent in this session)
SELECT * FROM TABLE(VALIDATE(raw.orders, JOB_ID => '_last'));

-- Is the pipe running and receiving notifications?
SELECT SYSTEM$PIPE_STATUS('raw.orders_pipe');

-- Files that landed before the pipe existed (or while it was paused): backfill
ALTER PIPE raw.orders_pipe REFRESH;   -- queues files staged in the last 7 days