Documentation Index
Fetch the complete documentation index at: https://docs.sqlbuild.com/llms.txt
Use this file to discover all available pages before exploring further.
Inspect upstream and downstream dependencies for any model, source, seed, or function in your project. Outputs as a tree, edge list, or structured JSON.
Usage
# Target mode: lineage around a single resource
sqb lineage <target> [flags]
# Selector mode: lineage for a selected scope
sqb lineage --select <selector> [flags]
Exactly one of a positional target or --select is required.
Flags
| Flag | Description |
|---|
--direction | upstream (default), downstream, or both. Only applies in target mode. |
--depth | How many hops to traverse. An integer or all (default: all). |
--format | Output format: tree (default), list, or json. |
--no-sql-validation | Skip compile-time SQL syntax validation. |
--select, -s | Select resources using standard selector syntax. |
--exclude | Exclude resources from the selection. |
Tree
The default. Shows an indented dependency tree with resource types and file paths:
sqb --project-dir examples/waffle_shop lineage fact_orders --direction both
Lineage model fact_orders models/marts/fact_orders.sql both
upstream
├── model stg_orders models/staging/stg_orders.sql
│ └── source raw_orders sources/raw.yml
├── model stg_payments models/staging/stg_payments.sql
│ └── source raw_payments sources/raw.yml
├── seed waffle_types seeds/waffle_types.csv
├── function is_completed_order functions/sql/is_completed_order.sql
└── function is_completed_order_py functions/python/is_completed_order_py.py
downstream
├── model customer_status_snapshot models/intermediate/customer_status_snapshot.sql
├── model hourly_order_activity models/marts/hourly_order_activity.sql
│ ├── model daily_activity_rollup models/marts/daily_activity_rollup.sql
│ │ └── model hourly_activity_with_daily_context models/marts/hourly_activity_with_daily_context.sql
│ │ └── model hourly_order_activity (already shown)
│ └── model hourly_activity_with_daily_context (already shown)
└── model order_status_index models/intermediate/order_status_index.sql
Cycles and repeated nodes are annotated with “(already shown)” to avoid infinite recursion.
List
An edge list showing each dependency as a directed pair:
sqb --project-dir examples/waffle_shop lineage fact_orders --format list
source:raw_orders -> model:stg_orders
source:raw_payments -> model:stg_payments
model:stg_orders -> model:fact_orders
model:stg_payments -> model:fact_orders
seed:waffle_types -> model:fact_orders
JSON
Structured output with nodes, edges, and metadata:
sqb --project-dir examples/waffle_shop lineage fact_orders --format json
{
"nodes": [
{
"id": "model:fact_orders",
"name": "fact_orders",
"resource_type": "model",
"relative_path": "models/marts/fact_orders.sql",
"qualified_name": "dev.fact_orders"
},
{
"id": "source:raw_orders",
"name": "raw_orders",
"resource_type": "source",
"relative_path": "sources/raw.yml"
}
],
"edges": [
{"from": "source:raw_orders", "to": "model:stg_orders"},
{"from": "model:stg_orders", "to": "model:fact_orders"}
],
"focus": ["model:fact_orders"],
"direction": "upstream"
}
Examples
# Upstream dependencies of a model (default)
sqb lineage fact_orders
# Downstream dependents
sqb lineage fact_orders --direction downstream
# Both directions, limited to 1 hop
sqb lineage fact_orders --direction both --depth 1
# Lineage for all models in a path
sqb lineage --select path:marts
# Lineage between two models (path-between)
sqb lineage --select "stg_orders~daily_activity_rollup"
# Upstream expansion from a model
sqb lineage --select "+fact_orders"
# JSON output for programmatic consumption
sqb lineage fact_orders --format json --direction upstream
Depth limiting
--depth controls how many hops from the focus node(s) to include. In selector mode, --depth requires name, source, seed, or path-between selectors - it cannot be combined with tag or path selectors or comma-intersection selectors.
# Only immediate parents
sqb lineage fact_orders --depth 1
# Parents and grandparents
sqb lineage fact_orders --depth 2