What is data lineage?
Data lineage is the record of where a dataset comes from and what is built from it: which sources feed a table, which transformations run in between, and which reports depend on the result. It is usually drawn as a directed graph from sources to dashboards.
What lineage answers
- Impact: if I rename a column in the orders table, which models and dashboards break?
- Root cause: this revenue number is wrong; which upstream table or step introduced the error?
- Audit: is this report built from the system of record, or from a spreadsheet someone uploaded?
- Privacy: which downstream tables hold data derived from a column with personal data?
How lineage is captured
There are three common sources. Declared lineage comes from the pipeline code: in dbt, every ref() and source() call is an edge, so dbt knows the whole graph before running anything. Parsed lineage comes from reading SQL: a parser such as sqlglot walks each statement and records which tables and columns feed which outputs. Observed lineage comes from runtime: query logs, or a standard like OpenLineage, where each job reports its inputs and outputs as it runs.
| Granularity | An edge means | Cost to get |
|---|---|---|
| Table level | Table B reads from table A | Low: dbt refs, or the tables in each FROM clause |
| Column level | B.revenue is computed from A.amount and A.status | Higher: full SQL parsing, including expressions and SELECT * |
Impact analysis with a recursive query
Once lineage is stored as edges, finding everything downstream of a table is a graph walk. This DuckDB query starts at a source table and follows edges until nothing new is reached.
CREATE TABLE lineage (upstream VARCHAR, downstream VARCHAR);
INSERT INTO lineage VALUES
('sales_pg.public.orders', 'stg_orders'),
('sales_pg.public.customers', 'stg_customers'),
('stg_orders', 'fct_orders'),
('stg_customers', 'fct_orders'),
('fct_orders', 'daily_revenue'),
('fct_orders', 'customer_ltv'),
('stg_customers', 'customer_ltv');
-- Everything downstream of the orders table, with distance
WITH RECURSIVE impact(node, depth) AS (
SELECT 'sales_pg.public.orders', 0
UNION
SELECT l.downstream, i.depth + 1
FROM lineage l JOIN impact i ON l.upstream = i.node
)
SELECT node, min(depth) AS depth
FROM impact
WHERE depth > 0
GROUP BY node
ORDER BY depth, node;It returns stg_orders at depth 1, fct_orders at 2, and customer_ltv and daily_revenue at 3. A change to the orders table touches four models, while stg_customers is unaffected. UNION rather than UNION ALL drops rows the walk has already produced, so a diamond in the graph doesn't multiply work.
Where lineage falls short
Lineage is only as complete as its inputs. Declared lineage misses anything outside the pipeline tool: an ad-hoc script, a BI tool's custom SQL, a manual export. Parsed lineage struggles with dynamic SQL and SELECT *. Observed lineage only sees jobs that actually ran. Most teams combine the pipeline's graph with query logs and accept that some edges, such as spreadsheets, stay manual. Lineage also says nothing about whether data is current; that is data freshness.
In Thunderduck
For dbt pipelines, the Pipelines page draws a project's or a run's model graph, with zoom, pan and click-to-focus, and colors each node by its status in that run, so a failed model and the models downstream of it are visible together. Query History rows from dbt open with a -- dbt: model.<project>.<name> line, which ties each statement back to its model.
Toward the sources, every statement Thunderduck pushes into BigQuery, PostgreSQL, MySQL, Oracle or SQL Server starts with a -- Thunderduck Query. comment carrying the query id and user id, so a DBA can trace a statement in the source's own log back to the run and user that sent it.
Docs: https://docs.thunderduck.ai/release-notes/2026-11/