liveBook · Manning

Declarative data transformation pipeline

As explained in Snowflake Data Engineering

A declarative data transformation pipeline specifies desired transformations and dependencies while the execution and maintenance are managed by the data platform.

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

How Snowflake Data Engineering covers it

How deep it goes
Explains query materialization, lag and warehouse configuration, refresh behavior, restrictions, and contrasts streams with background tracking.
Examples
Uses SPEEDY_ORDERS, SPEEDY_ORDERS_RAW_STG, JSON flattening, a one-minute target lag, and the BAKERY_WH warehouse.
What it assumes
Requires a source query, a target dynamic-table name, an acceptable lag, and a virtual warehouse.
What you can do after
Operate/configure dynamic tables that materialize transformed data and refresh within a declared lag.
How it connects
Connects dynamic tables with Snowpipe, streams, materialized views, target tables, merging, and task-based maintenance.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Snowflake Data Engineering. The section links point to the parts of the book it draws on.