A declarative data transformation pipeline defines the query results and dependencies to materialize, while Snowflake maintains the transformed data in the background. This replaces manually scheduled tasks or repeated inserts and merges with a platform-managed transformation layer. section 5.5 section 5.4
Implement the pattern with dynamic tables and configure its operational boundaries:
- Define a dynamic table using the query whose results should be materialized. section 12.5
- Set TARGET_LAG to bound acceptable staleness and WAREHOUSE to identify the refresh compute resource. section 5.4
- Prefer idempotent pipeline designs that avoid duplicates, gaps, and inconsistencies when execution repeats. section 12.5
- Use streams when explicit DML change metadata is needed, but dynamic tables track source changes in the background. section 12.5
Flattening staged order data
A dynamic table can flatten semi-structured order items from SPEEDY_ORDERS_RAW_STG, materialize the selected columns, tolerate at most one minute of lag, and refresh with BAKERY_WH. section 5.4
create dynamic table SPEEDY_ORDERS target_lag = '1 minute' warehouse = BAKERY_WH as select #1 order_id, order_datetime, value:"Item"::varchar as baked_good_type, value:"Quantity"::number as quantity, source_file_name, load_ts from SPEEDY_ORDERS_RAW_STG, lateral flatten (input => items);
Runnable SQL creates the SPEEDY_ORDERS dynamic table with target lag, warehouse, JSON flattening, and projected order fields. section 5.4
