Blueprints Blog Contact About

Dependency Graph

Your queries define the graph

Dependencies are automatic. Write queries. OndatraSQL figures out the order.

Mental Model

  • Files are nodes
  • SQL references create edges
  • Execution is automatic

You never define the DAG.

How Dependencies Are Detected

  • SQL models → table references from FROM, JOIN, CTEs, subqueries
  • Starlark modelsquery("...") calls (followed through load() imports)
  • YAML models → same as Starlark via source functions

Only references to other models create dependencies.

Limitation

Only static SQL is detected:

query("SELECT * FROM staging.orders")    # tracked
query("SELECT * FROM " + table)          # not tracked

Dynamic queries are silently skipped.

Execution Order

If a model reads another model, it runs after it.

raw.orders       → staging.orders
raw.customers    → staging.customers
staging.*        → mart.revenue
graph LR RO["raw.orders"] --> SO["staging.orders"] RC["raw.customers"] --> SO RC --> SC["staging.customers"] SO --> MR["mart.revenue"] SC --> MR style RO fill:#1a2332,stroke:#4a6fa5,color:#e0e0e0 style RC fill:#1a2332,stroke:#4a6fa5,color:#e0e0e0 style SO fill:#1a2332,stroke:#3ecfcf,color:#e0e0e0 style SC fill:#1a2332,stroke:#3ecfcf,color:#e0e0e0 style MR fill:#1a2332,stroke:#e8854a,color:#e0e0e0

Run Types

Each model gets a run type before execution:

Run TypeMeaning
skipNothing changed
backfillFirst run or definition changed
incrementalNew/changed data
fullUpstream changed

These decisions propagate through the graph.

Propagation

When a model runs, downstream models are re-evaluated. Changes flow through the DAG.

If a model fails, downstream models do not run.

Traditional Approach

@task
def staging_orders():
    ...

@task
def mart_revenue():
    staging_orders()

Manual DAG. Maintained by hand.

OndatraSQL:

SELECT * FROM staging.orders

DAG inferred automatically.

Commands

Run:

ondatrasql run                    # All models in DAG order
ondatrasql run staging.orders     # Single model

Preview:

ondatrasql sandbox

Inspect:

ondatrasql lineage overview           # All dependencies
ondatrasql lineage staging.orders     # One model

Circular dependencies are detected at build time.

Why This Matters

Most tools require defining dependencies manually, maintaining DAGs, and debugging execution order.

OndatraSQL builds the graph from your code. Your queries define the graph.