Skip to content

DAG & Dependencies

Rocky builds a DAG from your model dependencies and runs the models in that order. Edges come from two places, merged:

  • An explicit depends_on list in a model’s TOML.
  • A bare table name in the model’s SQL that another model writes as its [target] table. Rocky infers the edge and reports it as I001. The read can be anywhere in the query: FROM, JOIN, a CTE body, or a subquery in FROM, the SELECT list, WHERE, HAVING, QUALIFY, GROUP BY, ORDER BY or a join condition. A bare read of a model’s name whose target table is spelled differently is not an edge (D012). A binding by table alone that would close a cycle is dropped (D013).

Rocky then topologically sorts the merged set into layers that run in parallel.

Each model names what it depends on with depends_on in its TOML:

name = "fct_orders"
depends_on = ["stg_orders", "dim_customers"]

fct_orders cannot start until both stg_orders and dim_customers finish.

Rocky sorts with Kahn’s algorithm. The order is deterministic: models that are ready together sort alphabetically.

Every model in a layer can run at the same time, because earlier layers satisfied its dependencies. Rocky runs a whole layer at once, waits, then runs the next. Take this graph:

stg_customers ──→ dim_customers ──┐
├──→ fct_orders
stg_orders ───────────────────────┘

It produces three layers:

Layer 0: stg_customers, stg_orders (no dependencies, run in parallel)
Layer 1: dim_customers (depends on stg_customers)
Layer 2: fct_orders (depends on stg_orders + dim_customers)

Rocky runs all of Layer 0 at once, waits for it to finish, then runs Layer 1, and so on.

--parallel N caps how many nodes run at once. On rocky run it defaults to 4. Under rocky run --dag it applies only when you pass it: without it, every node in a layer runs at once.

The flag bounds nodes, not warehouse queries. A replication node takes its table fan-out from that pipeline’s [execution] concurrency (default 32), and --parallel does not govern that on either path. So rocky run --dag --parallel 1 runs one node at a time, and the replication node inside it may still copy several tables at once.

rocky validate checks the whole DAG before any SQL runs. It needs no warehouse connection.

Rocky reports a cycle as the set of models in it. Models that only read from the cycle are not listed. rocky compile reports E058 and exits 1. rocky run --dag refuses before it runs any node, so no table is written.

model_a.toml
name = "model_a"
depends_on = ["model_b"]
# model_b.toml
name = "model_b"
depends_on = ["model_a"]
Error: DAG error: circular dependency detected involving: ["model_a", "model_b"]

Rocky catches a reference to a model that does not exist:

name = "fct_orders"
depends_on = ["stg_orders", "nonexistent_model"]
Error: DAG error: unknown dependency 'nonexistent_model' referenced by 'fct_orders'

A close match adds — did you mean '<model>'?.

Not every table reference becomes a dependency. Rocky classifies a reference by how it is qualified (see Resolve dependencies): a bare name that matches a Rocky model is an execution edge. A bare name with no matching model, and any two-part or three-part name, is an external reference that the DAG ignores. Rocky reads an external table but does not manage, build or schedule it.

A Rocky model can therefore read a table another tool produced (a dbt package, a Fivetran connector, a hand-written ETL job) without importing it. External tables still appear in column-level lineage and are left out of execution planning.

See Read dbt Package Tables.