Model Format
A Rocky model is one SQL query plus the configuration that says how to materialize it, what it depends on, and where the output goes. One model produces one table or view.
Rocky reads two model formats: sidecar (recommended) and inline (legacy).
Model format at a glance
Section titled “Model format at a glance”Blocks, each described below: top-level keys, [strategy], [target], [[sources]], [skip], [args] and config groups, [classification], [tags], [governance.tags], [[surrogate_key]], [[tests]], [[use_test]], [[test]] (unit tests with mock inputs), [columns.NAME] and retention. Strategies are under Strategy Examples. [freshness], [budget], [redshift] and [clickhouse] are described under the field table.
A minimal model is two files:
name = "fct_orders"depends_on = ["stg_orders"]
[strategy]type = "merge"unique_key = ["order_id"]
[target]catalog = "analytics"schema = "warehouse"table = "fct_orders"The .sql file next to it holds a plain SELECT.
Sidecar Format (Recommended)
Section titled “Sidecar Format (Recommended)”Keep the SQL and the configuration in two files that share a name (models/fct_orders.sql, models/fct_orders.toml). The .toml file is the sidecar: it carries everything that is not SQL. The .sql file holds a plain query with no templating and no Jinja, so any SQL tool can open or run it.
SQL File
Section titled “SQL File”-- models/fct_orders.sqlSELECT o.order_id, o.customer_id, o.order_date, o.total_amount, c.customer_nameFROM analytics.staging.orders AS oJOIN analytics.staging.customers AS c ON o.customer_id = c.customer_idWHERE o.order_date >= '2024-01-01'TOML Config File
Section titled “TOML Config File”The .toml file names the model, lists what it depends on, picks a materialization strategy, and says where the output lands.
Fields:
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Model identifier. Must be unique across all models. |
drop_existing_kind |
"table" or "view" |
No | Standing permission to drop a target of this existing kind when switching between full_refresh and view. DuckDB only today. |
depends_on |
list of strings | No | Names of upstream models that must run before this one. Defaults to []. |
group |
string | No | Name of a config group (models/groups/<name>.toml) this model opts into for shared routing and materialization. |
access |
string | No | private, protected (default) or public. Who may reference the model. See Model governance. |
access_group |
string | No | Ownership group for access checks. Falls back to group. Inherits no config. See Model governance. |
retention |
string | No | Data retention policy for this model. Grammar ^\d+[dy]$ — e.g. "90d" or "1y". See Retention. |
adapter |
string | No | An [adapter.NAME] key from rocky.toml. Runs this model on that adapter instead of the pipeline’s. |
intent |
string | No | A plain-language description of what the model does. rocky ai-sync reads it. |
More sidecar blocks: [freshness] (warn_after, error_after, time_column; see [freshness]), [budget] (a per-model override of the project [budget], checked at compile time as E027), and the adapter-specific [redshift] and [clickhouse] blocks.
drop_existing_kind applies only when a full_refresh model finds a view, or a view model finds a table. Rocky checks the existing kind first. On DuckDB the DROP and CREATE run in one transaction. Rocky refuses a full_refresh or view model carrying this key on every other adapter. It is a standing permission on the model, not a one-time approval, and Rocky keeps no ownership record for the old object: confirm the target belongs to this model before you set it.
[args] – Placeholder values for a config group’s schema_template (ignored when the model declares no group). region = "emea" resolves mart_{region} to mart_emea. See Config groups.
[strategy] – Materialization configuration:
| Field | Type | Default | Description |
|---|---|---|---|
type |
string | "full_refresh" |
Materialization type. One of "full_refresh", "incremental", "merge", "time_interval", "view", "materialized_view", "dynamic_table", "delete_insert", "microbatch", "content_addressed", "ephemeral", "snapshot". "incremental" needs a watermark column, or compile fails with E037 (see Incremental). "ephemeral" is inlined into its readers; E038 marks a use that cannot work (see Ephemeral). See Snapshot for "snapshot". |
timestamp_column |
string | The watermark column. Required for incremental (alias watermark) and for microbatch, where it names the output partition column. |
|
unique_key |
list of strings | Key columns for merge matching. Required when type = "merge". |
|
update_columns |
list of strings | Columns to update on merge match. Defaults to all non-key columns if omitted. | |
partition_by |
list of strings | Column(s) identifying the partition to delete. Required when type = "delete_insert". |
|
time_column |
string | Partition column for time-interval processing. Required when type = "time_interval". |
|
granularity |
string | "hour" (microbatch) |
Partition granularity: "hour", "day", "month", or "year". Required when type = "time_interval"; optional default for "microbatch". |
lookback |
integer | 0 |
Number of past partitions to reprocess. Optional for "time_interval". |
batch_size |
integer | 1 |
Max partitions per batch. Optional for "time_interval". |
first_partition |
string | Earliest partition key (e.g., "2024-01-01"). Optional for "time_interval". |
|
storage_prefix |
string | Object-store key prefix that holds _delta_log/ + Parquet files for the target table (e.g. "s3://bucket/path/table"). Required when type = "content_addressed". |
|
partition_columns |
list of strings | [] |
Logical partition columns for content-addressed tables. Empty for unpartitioned tables. Optional for "content_addressed". |
[target] – Output table:
| Field | Type | Required | Description |
|---|---|---|---|
catalog |
string | Yes | Target catalog name. |
schema |
string | Yes | Target schema name. |
table |
string | Yes | Target table name. |
[[sources]] – Input tables (optional, for documentation and lineage):
| Field | Type | Required | Description |
|---|---|---|---|
catalog |
string | Yes | Source catalog name. |
schema |
string | Yes | Source schema name. |
table |
string | Yes | Source table name. |
[skip]
Section titled “[skip]”Overrule the --skip-unchanged gate for this one model. Omit the block and the automatic rules apply: a model is skip-eligible only when a static scan finds its SQL deterministic and it uses a plain materialization strategy.
| Field | Type | Default | Description |
|---|---|---|---|
eligible |
bool | null | null |
false: this model always builds, even when everything looks unchanged (a known-volatile model the scan might miss). true: eligible, subject to the other gate clauses. null: automatic rules. |
deterministic |
bool | null | null |
Owner assertion about the SQL’s purity. true is the only way a model the non-determinism scan flagged (timestamps, randomness, unresolved UDFs, order-unstable aggregates) becomes skip-eligible. false forces never auto-skipped. null: trust the scan. |
The gate builds on any doubt. deterministic = true overrides only the non-deterministic case. Full rules: What is and is not skip-eligible. Workflow: Skip Unchanged Models and Defer to Prod.
Environment variables
Section titled “Environment variables”Sidecar files and models/_defaults.toml get the same ${VAR} and ${VAR:-default} substitution as rocky.toml. An orchestrator can therefore set a model’s [target] through the subprocess environment, with no templating in the sidecar. See Environment variables for the syntax and a sidecar example, and examples/playground/pocs/00-foundations/07-config-layering/ for a runnable three-layer example.
@var() run variables
Section titled “@var() run variables”Parameterize a model per run. Write @var(name) or @var(name, default) in the model body and bind it with a repeatable rocky run --var name=value. Rocky substitutes the value into the SQL before it reaches the warehouse:
-- models/orders.sqlSELECT * FROM raw.ordersWHERE region = '@var(region)' AND status = '@var(status, shipped)'rocky run --var region=emea --var status=delivered@var(region) has no default, so you must supply it. A @var(name) with no binding and no default is a compile error naming the variable. The substitution is textual: you own the quoting and casting around the marker. Rocky validates only the variable name, as a SQL identifier. rocky import-dbt maps dbt’s {{ var('name') }} and {{ var('name', default) }} onto these markers.
${ENV} resolves while Rocky parses rocky.toml and the sidecars, before any model is read, and sets config values (target catalog, credentials). @var(name) resolves at compile time, stays visible in the model source, and sets a run’s logical inputs (a region, a status).
Config groups
Section titled “Config groups”Write shared settings once when a fan-out of models routes and materializes the same way. A config group lives in models/groups/<name>.toml (the file stem is the group name) and supplies a schema_template and a strategy. A model joins with group = "<name>" and fills the template’s placeholders from its own [args]:
schema_template = "mart_{region}"
[strategy]type = "merge"unique_key = ["id"]update_columns = ["amount", "status"]group = "daily_marts"
[target]catalog = "warehouse" # schema comes from the group template
[args]region = "emea" # fills {region} -> schema "mart_emea"Three layers can set the same field. The nearest one to the model wins: the model’s sidecar, then models/groups/<name>.toml, then models/_defaults.toml.
A group naming no definition fails the load, and so does a schema_template placeholder the model does not supply. A group owns a model’s schema only when the group sets schema_template. A model that pins its own schema bypasses the template, so it must not also supply [args]: pin a schema or supply args, never both.
A group file may carry schema_template, strategy, tags, governance, enforce, and [owner] (name, email; see Model governance). Rocky rejects an unrecognized key at load. The model loader does not recurse, so it never reads models/groups/ as model files.
Enforced groups
Section titled “Enforced groups”Set enforce = true in the group file (opt-in; otherwise a group is overridable defaults). A member that pins a field the group owns, its target schema or its strategy, then fails the load with GroupOverride. It may still supply its own [args] and any field the group leaves unset, such as target.catalog. Use it when models must share routing and materialization as a governance guarantee.
Group tags
Section titled “Group tags”A group can declare a [tags] block that every member inherits as a baseline. A model’s own [tags] override it key by key: a model can set tier = "silver" and still inherit domain = "finance". See [tags].
[classification]
Section titled “[classification]”Label a column as sensitive so the masking policy can act on it. Keys are column names. Values are free-form classification strings ("pii", "confidential", "internal"), matched case-insensitively against [mask] and [mask.<env>] in rocky.toml to pick a strategy. Rocky applies the column tag and the mask through the governance adapter after a successful DAG run. A tag without a matching strategy emits W004 unless listed in [classifications] allow_unmasked.
name = "customers"
[classification]email = "pii"ssn = "confidential"Masking works today on Databricks Unity Catalog only (column tags plus CREATE MASK / SET MASKING POLICY, one statement per column), best-effort. End-to-end story: Governance. Resolver semantics: [mask].
[tags]
Section titled “[tags]”Describe the model as a whole: its domain, tier, owner, or anything else your governance model needs. [classification], by contrast, is keyed by column and drives masking.
| Key pattern | Value type | Description |
|---|---|---|
<tag_name> |
string | Free-form attribute. Merged over any config-group [tags] baseline (sidecar wins). |
rocky compile --output json reports the resolved tags as models_detail[].tags, and dagster-rocky projects them onto the derived asset’s Dagster tags. [tags] never touches the warehouse: use [governance.tags] for that.
[governance.tags]
Section titled “[governance.tags]”Put a tag on the warehouse object itself. After the model materializes, Rocky writes these as Unity Catalog tags on its own target table or view: ALTER VIEW … SET TAGS (…) for a view-format model, ALTER TABLE … SET TAGS (…) otherwise.
[governance.tags]domain = "finance"tier = "gold"| Key pattern | Value type | Description |
|---|---|---|
<tag_name> |
string | Unity Catalog tag on this model’s target table or view. Keys and values are used verbatim, with no prefix. |
This is the per-model counterpart to the pipeline-level tagging strategy. It is best-effort (a failure warns and never aborts the run), and an empty block is skipped because Unity Catalog rejects SET TAGS ().
[[surrogate_key]]
Section titled “[[surrogate_key]]”Add a stable key column without writing the hash expression. Rocky injects a deterministic hash over the columns you list into the model’s SELECT.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Output column name. A valid SQL identifier (^[a-zA-Z0-9_]+$). |
columns |
list of strings | Yes | Input columns to hash. At least one, each a valid SQL identifier. |
[[surrogate_key]]name = "customer_sk"columns = ["tenant_id", "customer_id"]At rocky run (and on the emit-SQL path), Rocky appends CAST(md5(...) AS <string_type>) AS <name> to the projection, in the dialect’s form (STRING on Databricks and BigQuery, VARCHAR on Snowflake, DuckDB and Trino; BigQuery uses to_hex(...) / concat(...)). The hash matches dbt_utils.generate_surrogate_key over the same columns on the same warehouse, so keys join across Rocky and dbt models. NULL inputs coalesce to a fixed sentinel first. The block refuses an unknown key (colums = [...] fails the load), an empty columns list, and a name or column that is not a valid identifier. Declare several blocks for several key columns.
[[tests]]
Section titled “[[tests]]”Assert a property of the model’s output. Each [[tests]] block is one assertion that runs against the target table. Rocky generates the SQL for the target dialect.
| Field | Type | Required | Description |
|---|---|---|---|
type |
string | Yes | Assertion kind. Common types: not_null, unique, accepted_values, relationships, expression, row_count_range. Others: in_range, regex_match, aggregate, composite-key uniqueness. |
column |
string | Sometimes | Column under test. Required for not_null, unique, accepted_values, relationships. Ignored for expression and row_count_range. |
severity |
string | No | "error" (default) fails the run; "warning" records the failure and continues. |
filter |
string | No | SQL boolean predicate that scopes the assertion. Rows where it is FALSE or NULL pass unconditionally. |
Type-specific fields: accepted_values takes values, relationships takes to_table and to_column, expression takes an expression (a SQL boolean that must hold for every row), row_count_range takes min and/or max (inclusive).
[[tests]]type = "not_null"column = "order_id"
[[tests]]type = "expression"expression = "amount >= 0"filter = "status != 'cancelled'"expression and filter share one gate. Rocky parses them under the target dialect and refuses, before anything runs, a subquery, a qualified function name (schema.fn(...)) or a function outside its allowlist of pure scalar functions. Comparisons, CASE, CAST, coalesce, length, lower and date_trunc pass. The refusal names the function. See Per-assertion filter.
[[use_test]]
Section titled “[[use_test]]”Apply a test you defined once, by name, when several models share the same assertion. A named definition lives in models/test_definitions.toml, keyed by name, with the test type, its parameters and an optional default column:
[positive_amount]type = "expression"expression = "amount > 0"
[known_status]type = "accepted_values"values = ["pending", "shipped", "delivered"]column = "status"A model applies one with [[use_test]]:
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Name of the definition. An unknown name fails the load. |
column |
string | No | Column to bind the test to. Overrides the definition’s column. |
severity |
string | No | Failure severity here. Defaults to error. |
filter |
string | No | Row-scoping SQL predicate, same contract as an inline test’s filter. |
[[use_test]]name = "known_status"column = "order_status" # override the definition's default columnRocky appends resolved references to the model’s [[tests]] at load and rejects a mistyped key (colum =, filer =).
[[test]]
Section titled “[[test]]”Check the model’s SQL logic against inputs you write by hand, with no warehouse involved. Rocky seeds mock upstream tables, runs the model’s SQL over them, and compares the result to the rows you expect. Where [[tests]] asserts a property of real materialized output, [[test]] tests the logic itself. Note the singular block name: [[test]] here, [[tests]] for declarative assertions.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Test name. Unique within the model. |
description |
string | No | Free-form note describing what the test covers. |
Each test declares one or more input fixtures and one expected output:
[[test.given]]— a mocked upstream model or source.refis the name to mock (matches adepends_onorfromreference);rowsis an inline list of TOML tables seeded as that table’s contents.[test.expect]— the expected output.rowsis the list of expected output rows. Setordered = trueto require the output in exactly this order; the default is a multiset comparison where row order doesn’t matter.
name = "high_value_orders"
[[test]]name = "flags_orders_over_100"description = "Orders over $100 should be flagged as high value"
[[test.given]]ref = "orders"rows = [ { id = 1, amount = 150.0, status = "completed" }, { id = 2, amount = 50.0, status = "completed" }, { id = 3, amount = 200.0, status = "cancelled" },]
[test.expect]rows = [ { id = 1, amount = 150.0, is_high_value = true }, { id = 3, amount = 200.0, is_high_value = true },]A test may declare several [[test.given]] blocks to mock more than one upstream, and a model may declare several [[test]] blocks.
rocky test runs every [[test]] on DuckDB. For a model whose target warehouse is not DuckDB alone, each result says so, and rocky test --strict-dialect refuses the test. See unit tests on a warehouse that is not DuckDB.
[columns.<name>]
Section titled “[columns.<name>]”Document what an output column means. Each [columns.<name>] table describes one column:
| Field | Type | Description |
|---|---|---|
description |
string | Natural-language description of the column. |
Write one table per column, for example [columns.order_id] with description = "Unique order identifier".
rocky catalog --output json reports each description as the asset’s CatalogColumn.description. Rocky attaches a description only when <name> matches a column the model actually projects. It drops a description for a column the SELECT does not produce, silently, so keep these keys in step with your output columns. rocky docs shows each description next to its column on the model page. It takes the column list from the offline compile, so it needs no warehouse connection.
[columns.<name>] documents columns. It differs from the [[columns]] array that declares a contract’s column schema.
Retention
Section titled “Retention”Declare how long this model’s data should be kept with the top-level retention key. Rocky parses it at load into a typed RetentionPolicy { duration_days: u32 }.
| Field | Type | Default | Description |
|---|---|---|---|
retention |
string | null | null (disabled) |
Grammar ^\d+[dy]$. "d" is days, "y" is years flattened at 365 days. Zero ("0d", "0y") is rejected: use null to disable. |
Example: retention = "90d". Rocky applies it through GovernanceAdapter::apply_retention_policy after a successful DAG run: Delta table properties on Databricks, DATA_RETENTION_TIME_IN_DAYS on Snowflake, nothing on other adapters (see Governance). A malformed value ("abc", "90", "-3d", "1.5d", a sign, an exponent) fails the sidecar parse with ModelError::InvalidRetention. Inspect resolved policies with rocky retention-status.
Inline Format (Legacy)
Section titled “Inline Format (Legacy)”The inline format puts the TOML in a ---toml / --- fenced block at the top of the .sql file, with the same fields as the sidecar. The SQL query follows the closing ---. The frontmatter gets the same ${VAR} and ${VAR:-default} substitution as a sidecar (Environment variables). The SQL body gets none: a ${VAR} token in the query stays literal. The format exists for backward compatibility. Prefer the sidecar.
---tomlname = "stg_orders"depends_on = []
[target]catalog = "analytics"schema = "staging"table = "orders"---
SELECT order_id, customer_id, order_date, total_amountFROM raw_catalog.src__acme__us_west__shopify.ordersStrategy Examples
Section titled “Strategy Examples”Full Refresh
Section titled “Full Refresh”Drops and recreates the target table on every run, with type = "full_refresh". Use it for small dimension tables or a clean rebuild. Rocky runs CREATE OR REPLACE TABLE <target> AS <model SELECT>.
Incremental
Section titled “Incremental”Loads only the rows newer than what the target already holds. Use it when the source has a column whose values only grow, such as updated_at. The column is the model’s watermark (the value of the newest row already loaded).
SQL (models/fct_orders.sql):
SELECT order_id, customer_id, amount, status, updated_atFROM raw.ordersWHERE @incremental_filterConfig (models/fct_orders.toml):
[strategy]type = "incremental"timestamp_column = "updated_at" # the watermark; `watermark` is an aliasunique_key = ["order_id"] # optional: MERGE on this key instead of appendinglookback = "2 days" # optional: re-read this far below the watermarkon_schema_change = "fail" # or "append_new_columns"| Key | Required | Meaning |
|---|---|---|
timestamp_column |
yes | An output column. Rocky reads MAX of it from the target each run. Alias: watermark. |
unique_key |
no | Upsert on these columns with MERGE. Without it, Rocky appends. |
lookback |
no | "<n> seconds", "minutes", "hours" or "days". Re-reads late rows. Pair it with unique_key, or the re-read rows are appended again (W046). |
on_schema_change |
no | fail (default) stops the run when the model’s columns differ from the target’s. append_new_columns adds new columns with ALTER TABLE ... ADD COLUMN. A removed column fails the run in both modes. |
filter_column |
no | The input column @incremental_filter compares, when it is not the watermark itself: "o.updated_at" in a join, or "_synced_at" when the model renames it. |
How Rocky resolves @incremental_filter
Section titled “How Rocky resolves @incremental_filter”The placeholder marks where the filter goes. Rocky replaces it on every run:
run @incremental_filter becomes ─────────────────────────── ────────────────────────────────────────────── first run (no target yet) TRUE → CREATE TABLE AS rocky run --full-refresh TRUE → CREATE OR REPLACE every later run (updated_at > (SELECT MAX(updated_at) FROM <target>) OR NOT EXISTS (SELECT 1 FROM <target>)) → INSERT or MERGERocky reads the watermark from the target, not from its state store, so a manual edit of the target moves it. The NOT EXISTS arm loads every row when the target exists but is empty. A lookback subtracts its interval from MAX. Rows whose watermark is NULL load only on the first run and on a full refresh. The run output reports the new MAX as metadata.watermark (when it is a timestamp), and notes names the value the run started from.
A model without the placeholder
Section titled “A model without the placeholder”Rocky can filter the model’s output instead: SELECT * FROM (<model>) AS _rocky_incremental WHERE <filter on the output column>. This gives the same rows only when the watermark column is copied unchanged from one input table. rocky compile proves that with column lineage and refuses a column read from a CTE or subquery, and a model with a top-level LIMIT. filter_column has no effect here. When it cannot prove it, compile fails with E046. A model in the .rocky DSL always takes this path, because the DSL has no placeholder.
What rocky compile refuses
Section titled “What rocky compile refuses”| Code | Cause |
|---|---|
E037 |
type = "incremental" with no timestamp_column. Rocky could only append every row again on each run. |
E046 |
No placeholder and the watermark is not a provable passthrough. Also: the watermark is missing from the model’s output, timestamp_column or filter_column is not a plain column name, or @incremental_filter appears in a model of another strategy. |
W046 |
lookback without unique_key. |
W056 |
No lookback. The filter is a strict >, so a late row whose timestamp equals the target’s MAX is never loaded. unique_key alone does not fix this: it merges only the rows the filter reads. Set lookback with unique_key. |
rocky run records a refused model as a failed table, leaves its existing table alone, and withholds every model that depends on it. With contain_failures = true under [resilience] (the default), the same holds for a model that fails while it runs. See [resilience]. On a replication pipeline, incremental copies source tables and filters each copy on a watermark in the state store: see Incremental processing.
Upserts on a unique key: Rocky updates a row whose key exists and inserts one whose key does not. Use it for a slowly changing dimension or any table with late-arriving updates.
[strategy]type = "merge"unique_key = ["customer_id"]update_columns = ["customer_name", "email", "segment"] # default: all non-key columnsRocky runs MERGE INTO <target> AS target USING (<model SELECT>) AS source ON target.customer_id = source.customer_id, sets each update_columns column WHEN MATCHED, and inserts the row WHEN NOT MATCHED.
Ephemeral
Section titled “Ephemeral”An ephemeral model is never materialized. Each model that reads it gets its SQL as a CTE (a named subquery in a WITH clause), as in dbt’s materialized='ephemeral'. Set [strategy] type = "ephemeral". A consumer reads it by bare name, FROM eph_paid_orders, and Rocky runs the consumer as:
WITH __rocky_ephemeral__eph_paid_orders AS ( SELECT order_id, customer_id, amount FROM raw.orders WHERE status = 'paid')SELECT customer_id, SUM(amount) AS totalFROM __rocky_ephemeral__eph_paid_orders AS eph_paid_ordersGROUP BY customer_id- The CTE is named
__rocky_ephemeral__<model>(_2,_3if taken) and goes in front of anyWITHclause the consumer has. - A reference with no alias keeps the model name as its alias. Only a bare model name is a reference, and a CTE of the same name in the consumer wins.
- An ephemeral model that reads another works: one CTE each, in dependency order, once per consumer.
- The rewrite works on parsed SQL, so the consumer’s executed SQL loses its comments and spacing.
Commands: rocky compile type-checks the model and its consumers as written (--expand-macros shows each consumer with the CTE inlined). rocky run skips it, it never appears in materializations, rocky run --dag marks its node skipped, and its consumers still run. rocky run --model <ephemeral> fails with E038: nothing to build. rocky plan and rocky emit-sql list it as skipped. Shadow and branch runs skip it and route the reads inside its inlined SQL to shadow targets.
rocky compile reports E038 for a use that cannot work: the model declares [[tests]] (there is no table to test); another model reads its nominal [target] by a qualified name such as main.eph_paid_orders (read it by bare name); or a consumer cannot be rewritten (its SQL is not one SELECT the parser accepts, or a WITH RECURSIVE CTE has the same name as a table the inlined SQL reads). A contract on an ephemeral model is checked at compile time against the inferred columns.
Delete + Insert
Section titled “Delete + Insert”Deletes the rows in a partition (a slice identified by a column value), then inserts fresh ones. It costs less than merge when the partition key identifies exactly the rows you rewrite.
[strategy]type = "delete_insert"partition_by = ["activity_date"]Microbatch
Section titled “Microbatch”An alias for time_interval that defaults to hour granularity (the name matches dbt’s). The SQL must use both @start_date and @end_date to bound each partition, as in Time Interval. A missing placeholder is compile error E024. A placeholder counts as missing when it appears only in a comment, a string or the SELECT list, when it does not bound a column in an AND-joined comparison (ts >= @start_date OR 1 = 1, NOT (ts >= @start_date)), or when the filter misses emitted rows (an unfiltered UNION ALL branch, a filter in a CTE the output never reads, a filter in a scalar subquery in the SELECT list). See Time interval. Each run replaces its selected partitions instead of appending.
[strategy]type = "microbatch"timestamp_column = "event_at" # TIMESTAMP column on the model output# granularity = "hour" # optional, defaults to hourContent-Addressed
Section titled “Content-Addressed”Writes the model’s SELECT result to a Delta UniForm table as content-addressed Parquet (blake3-hashed file names) plus a Delta log commit, for cross-engine reads from DuckDB, Trino, Spark and any Iceberg-compatible reader. Rocky owns the writer (rocky-iceberg) and consumers read directly from the object store. See Content-Addressed Materialization.
[strategy]type = "content_addressed"storage_prefix = "s3://${ROCKY_BUCKET}/marts/fct_events"partition_columns = ["event_date"] # omit for an unpartitioned tableThe runtime executes the model SQL, converts the result to Arrow, hashes the Parquet bytes, uploads to storage_prefix and emits a Delta log commit.
Snapshot
Section titled “Snapshot”A snapshot keeps the history of its model’s rows. This is a slowly changing dimension of type 2 (SCD2): each change to a row adds a new version and closes the old one. Rocky follows dbt snapshots, but a snapshot here is an ordinary model. It runs in the model DAG under rocky run, and downstream models can read it.
Config (models/customers_history.toml):
[strategy]type = "snapshot"unique_key = "customer_id" # one column, or a list for a composite keystrategy = "timestamp" # or "check"updated_at = "updated_at" # timestamp strategy: the change column# check_cols = ["name", "email"] # check strategy: a list, or "all"hard_deletes = "invalidate" # "ignore" (default), "invalidate", "new_record"
[target]catalog = "analytics"schema = "snapshots"table = "customers_history"The model SQL is a plain SELECT, for example SELECT customer_id, name, email, updated_at FROM raw.customers.
How a change is detected. timestamp: a row changed when its updated_at is later than the current version’s, and the new version’s valid_from is that updated_at. check: a row changed when a column in check_cols differs from the current version (NULL counts as a value; "all" compares every column except the key), and valid_from is the run time, or the updated_at column when you also set one.
Columns Rocky adds to each row:
| Column | Meaning |
|---|---|
valid_from |
When this version became current. |
valid_to |
When this version stopped being current. NULL on the current version. |
is_current |
TRUE on the current version of each key. |
snapshot_id |
A hash of the key and valid_from, unique per version. |
is_deleted |
Only with hard_deletes = "new_record": TRUE on a deletion marker. |
Rename any of these with snapshot_meta_column_names. The dbt key names are accepted too, so an imported dbt config reads unchanged:
[strategy]type = "snapshot"unique_key = ["id", "region"]strategy = "check"check_cols = "all"snapshot_meta_column_names = { valid_from = "dbt_valid_from", valid_to = "dbt_valid_to", scd_id = "dbt_scd_id", updated_at = "dbt_updated_at", is_current = false }valid_to_current = "CAST('9999-12-31' AS TIMESTAMP)"updated_at in snapshot_meta_column_names adds a copy of the version’s change time (dbt’s dbt_updated_at, off by default). is_current = false writes no flag column: a version is then current when its valid_to is NULL or equals valid_to_current (use it to continue a snapshot table that dbt built). valid_to_current (dbt’s dbt_valid_to_current) is a SQL expression written to valid_to on current versions instead of NULL. invalidate_hard_deletes = true is accepted as dbt’s older spelling of hard_deletes = "invalidate".
What a run does:
first run CREATE TABLE ... AS: every row becomes its first current versionlater runs 1. MERGE close the current version of each changed key 2. INSERT a new current version for each key with no current version 3. hard deletes (when not "ignore"): invalidate UPDATE: close the current version of each key that left the result new_record INSERT a deletion marker, then UPDATE: close the version it replacesThe statements run in sequence, without a transaction, because not every warehouse has multi-statement transactions. Each step is safe to repeat: a run that stops after step 1 leaves some keys with no current version and the next run’s step 2 opens them; step 2 inserts only where no current version exists; a deletion marker is not inserted twice; a run over an unchanged source writes nothing. All statements in one run use one timestamp for “now”, so a closed version and its successor meet exactly.
Limits:
unique_key,updated_atandcheck_colsmust name output columns. To key on an expression, compute it in the model SQL. The key must be unique in the result (Databricks and Snowflake refuse the MERGE otherwise).- A row with a NULL key is not snapshotted: it never matches its earlier version, so it would be inserted on every run.
is_deletedis a metadata column only underhard_deletes = "new_record". Under the other modes a model column with that name is ordinary data. If you leavenew_record, keys whose current version is a deletion marker still reopen when they return.- The target keeps the columns it was created with. A column added later is not captured, and
rocky runreports it in the model’snotes. Drop the target to rebuild the history with it. rocky planandrocky emit-sqlshow steady-state statements built from the compile-time column list.rocky runreads the column list from the target.- A
branchpromotion and a shadow run refuse a snapshot model. - Each statement reads the model SELECT again, so a source that changes mid-run can look different to two statements. The next run reconciles it.
- Databricks and Snowflake have not run these statements live yet. On Databricks the run timestamp is a session-time-zone
TIMESTAMP, and a SELECT with a subquery may be refused inside the hard-deleteUPDATE.
rocky compile reports an invalid config as E049 and a risky one as W049. See the diagnostic codes.
Time Interval
Section titled “Time Interval”Rebuild one time slice at a time instead of the whole table. Write @start_date and @end_date placeholders in the model SQL, and Rocky substitutes the bounds of each partition as it processes it.
SQL (models/fct_daily_events.sql):
SELECT event_date, event_type, COUNT(*) AS event_countFROM raw_catalog.events.page_viewsWHERE event_date >= @start_date AND event_date < @end_dateGROUP BY event_date, event_typeConfig (models/fct_daily_events.toml):
name = "fct_daily_events"
[strategy]type = "time_interval"time_column = "event_date"granularity = "day"lookback = 3first_partition = "2024-01-01"
[target]catalog = "analytics"schema = "warehouse"table = "fct_daily_events"CLI flags. Every flag is accepted on rocky plan and on the single-step rocky run alias. The auditable form is rocky plan <flag> then rocky apply <plan-id>.
| Flag | Effect |
|---|---|
--partition 2026-04-01 |
Process one partition. |
--from 2026-03-01 --to 2026-04-01 |
Process a date range. |
--latest |
Process the latest partition. |
--missing |
Discover and process missing partitions from the stored partition records. |
--lookback 7 |
Set the lookback window. |
--parallel 4 |
Parallelize partition processing. |
DAG Resolution
Section titled “DAG Resolution”You never write an execution order. Rocky derives it from depends_on and the table references in each model’s SQL, and runs models in topological order: every upstream finishes before anything that reads it starts. Models at the same depth run concurrently, up to rocky run --parallel <N> (default 4). A warehouse that cannot run statements concurrently (DuckDB), and a depth that holds a content_addressed or time_interval model, run one at a time.
stg_orders ─────┐ ▼ stg_customers ─► fct_orders ─────► mart_revenue depth 0: stg_orders, stg_customers, dim_products ▲ depth 1: fct_orders dim_products ─────────────────────────┘ depth 2: mart_revenuerocky validate checks the DAG for cycles and fails with an error naming the loop: !! dag_validation — cycle detected: fct_orders -> dim_customers -> fct_orders.