Sub topic 9
What lineage does not capture, and how long it is kept
This chapter assumes you can query system.access.table_lineage and system.access.column_lineage, and that you know lineage is captured at runtime. Lineage is a record of what happened on Unity Catalog-enabled compute. It is not a complete map of your data estate. Before you use it for impact analysis or an audit, you need to know where it is blind and when it expires.
Lineage is captured only from runs that happened
Unity Catalog records lineage when a query or job executes. It does not scan table definitions or notebook code ahead of time. This has three consequences:
- Lineage starts when a workload first runs after the feature applies. It is not rebuilt for past runs.
- A pipeline that has not run recently may not show up in your search window. A quarterly job is easy to miss.
- Code that exists but never executed has no lineage.
Common gaps
The table below lists the gaps that cause most surprises. Databricks changes the exact supported scenarios over time, so check the current lineage documentation before you rely on a gap or a guarantee.
| Situation | What you typically see |
|---|---|
| Work on compute that is not Unity Catalog-enabled, or on `hive_metastore` tables | No lineage, or a partial graph |
| Reads and writes by file path instead of table name | A path appears as the source or target, not a table |
| Data moved by tools outside Databricks, such as an external ETL service writing files | No link between the upstream system and your table |
| Column lineage for logic the engine cannot trace to a named column | Table lineage exists but column rows are missing |
| Objects you cannot access | Hidden in Catalog Explorer, even though they exist |
Path-based access is the gap you can see most easily. The source_path and target_path columns hold the path when no table is involved. The following query lists such reads for a target table:
SELECT DISTINCT
source_path,
source_type,
entity_type
FROM system.access.table_lineage
WHERE target_table_full_name = 'main.sales.daily_revenue'
AND source_table_full_name IS NULL
AND source_path IS NOT NULL;If this returns rows, part of the upstream chain is a file location. Trace it by hand or change the code to read from a registered table.
Retention
The lineage system tables keep a rolling window of about one year (365 days) of events. Older rows are removed. Audit data in system.access.audit follows a similar rolling window. Confirm the current figure in the documentation for your cloud.
Retention affects your work in two ways:
- A dependency that has not run in over a year no longer appears, even though the job still exists.
- Rows for a dropped table remain until they age out. Querying by name can return history for an object that is gone.
If you need evidence for longer than the window, copy the rows into a table you own on a schedule. This example keeps a running archive. It assumes the main.governance.lineage_archive table already exists with the same columns as the lineage table:
INSERT INTO main.governance.lineage_archive
SELECT *
FROM system.access.table_lineage
WHERE event_date >= current_date() - INTERVAL 2 DAYS
AND NOT EXISTS (
SELECT 1
FROM main.governance.lineage_archive a
WHERE a.event_time = system.access.table_lineage.event_time
AND a.source_table_full_name <=> system.access.table_lineage.source_table_full_name
AND a.target_table_full_name <=> system.access.table_lineage.target_table_full_name
);Tighten the match condition to fit your needs. The overlapping two-day window protects against late-arriving rows.
Checking coverage before you trust a result
Before you base a decision on lineage, check how much history you have for the object:
SELECT
min(event_time) AS earliest_event,
max(event_time) AS latest_event,
count(*) AS row_count
FROM system.access.table_lineage
WHERE target_table_full_name = 'main.sales.daily_revenue'
OR source_table_full_name = 'main.sales.daily_revenue';An earliest_event close to the retention limit means older activity may have expired. A latest_event far in the past means the table may be idle, or lineage may not be reaching it.
Exercise
A table has no downstream rows in system.access.table_lineage. A teammate wants to drop it. Give two reasons the result might be misleading and one step to take before dropping.
Show answer
Downstream readers may use file paths or compute outside Unity Catalog, so no table-to-table link was recorded. A reader may also run less often than the retention window (about one year), so its events have expired. Before dropping, check the path columns for path-based reads, ask the owning teams, and check recent audit events for access to the table.