Glossary · Data observability and quality
What is data lineage?
Data lineage is the map of where data comes from, how it is transformed and where it goes: which jobs read which tables to produce which tables, views and dashboards. It is used to find the root cause of bad data, assess the impact of changes and prove compliance.
What lineage answers
- Upstream (root cause): this dashboard is wrong; which tables and jobs feed it, and which of them changed?
- Downstream (impact): I am about to drop this column or this table broke; what depends on it?
- Compliance: where does personal data flow, and who can reach it?
- Cost: which expensive pipelines feed tables nobody reads?
Lineage is a graph: nodes are tables, views, files and dashboards; edges are the jobs or processes that read one and write another. Column-level lineage refines edges down to individual columns.
How it is built on BigQuery
Every BigQuery query job records referenced_tables and destination_table, so a basic table-level lineage is one query away:
SELECT DISTINCT
CONCAT(src.dataset_id, '.', src.table_id) AS source_table,
CONCAT(destination_table.dataset_id, '.', destination_table.table_id) AS target_table
FROM `region-us`.INFORMATION_SCHEMA.JOBS,
UNNEST(referenced_tables) AS src
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
AND job_type = 'QUERY'
AND state = 'DONE'
AND error_result IS NULL
AND destination_table.table_id IS NOT NULL
AND NOT STARTS_WITH(destination_table.dataset_id, '_') -- skip anonymous result datasets
ORDER BY target_table, source_table;
That covers one project and region and misses load jobs from files, views and anything outside BigQuery. Fuller options:
- Knowledge Catalog data lineage (formerly Dataplex Universal Catalog): enable the Data Lineage API and BigQuery reports lineage for copy, load and query jobs automatically, including column-level links for many query types. It keeps 30 days of history, is billed for processing and metadata storage, and is enabled per project.
- Cloud Audit Logs:
TableDataReadandTableDataChangeevents record reads and writes across all projects, which also catches consumers such as BI tools. - Transformation tools: dbt and Dataform know their own model graph, but not ad hoc jobs or consumers outside the project.
Observability tools combine these sources; Masthead, for example, builds cross-project lineage down to columns and Looker assets from BigQuery logs, without reading data.
Pitfalls
- Lineage from code only. Parsing SQL in a repository misses jobs run outside it, which are often the ones that break things.
- Stale graphs. Lineage that is not rebuilt from recent jobs shows pipelines that no longer exist.
- No consumers. A graph that stops at the warehouse cannot answer which dashboards are affected.
- Short retention. If lineage is kept for 30 days, a monthly job may drop out of the graph between runs.
FAQ
How is data lineage collected in BigQuery?
From the jobs that move data. Each query, load or copy job records the tables it read and the table it wrote, in INFORMATION_SCHEMA.JOBS and in Cloud Audit Logs. Knowledge Catalog (formerly Dataplex Universal Catalog) builds lineage automatically from these jobs when the Data Lineage API is enabled in a project.
How long does Google keep data lineage?
Knowledge Catalog retains lineage information for 30 days, and BigQuery lineage appears within 24 hours after a job completes. For longer history, store the lineage yourself, for example from job metadata or audit logs.
