Sub topic 7
Tracing individual columns with system.access.column_lineage
This chapter assumes you can read the table-level lineage covered earlier, that you know system.access.table_lineage, and that your group already has SELECT on the lineage system tables. You should also be comfortable with the catalog.schema.table namespace.
Why column lineage
Table lineage tells you that main.sales.daily_revenue was built from main.sales.orders. It does not tell you which columns were involved. Suppose you plan to rename orders.amount_usd. A table-level answer says "everything downstream might break". A column-level answer says which downstream columns actually depend on it.
Unity Catalog records column lineage at runtime, in the same way as table lineage. The records are exposed in system.access.column_lineage.
What the table contains
Each row records one read-and-write relationship between a source column and a target column. The fields used most often are:
| Column | Meaning |
|---|---|
| `source_table_full_name` | Table the data was read from |
| `source_column_name` | Column that was read |
| `target_table_full_name` | Table the data was written to |
| `target_column_name` | Column that was written |
| `entity_type` | Kind of job or notebook that did the work |
| `event_time` | When the operation ran |
Rows come from executed workloads. A column that has never been read by a query that wrote somewhere will not show up.
Trace upstream: where does a column come from?
Start from a target column and look backward.
SELECT DISTINCT
source_table_full_name,
source_column_name,
target_column_name
FROM system.access.column_lineage
WHERE target_table_full_name = 'main.sales.daily_revenue'
AND target_column_name = 'revenue';If revenue is computed as SUM(amount_usd * fx_rate), you should see both amount_usd and fx_rate as source columns. A derived column can have several sources, so expect several rows.
Trace downstream: what depends on a column?
Reverse the filter to see what would be affected by a change.
SELECT DISTINCT
target_table_full_name,
target_column_name,
entity_type
FROM system.access.column_lineage
WHERE source_table_full_name = 'main.sales.orders'
AND source_column_name = 'amount_usd'
AND target_table_full_name IS NOT NULL;The IS NOT NULL filter removes reads that did not write to a table, such as a dashboard query that only displayed results.
Reading the results with care
- Use
DISTINCT. The same relationship is recorded on every run, so without it you get one row per execution. - Add a time filter on
event_timeto focus on recent behavior. An old pipeline that no longer runs can still appear. - A table appearing as a target means a workload wrote to it, not that the data is current.
- Results only include what the querying user is allowed to see. Lineage for tables you cannot access is hidden, so a short result is not proof of no dependency.
A practical workflow
- Identify the column you want to change.
- Run the downstream query with a recent
event_timefilter. - List the distinct target tables and columns.
- Check the owners of those tables and notify them.
- Repeat for the next hop, using each target as a new source.
Each hop is a separate query. Column lineage does not give you a recursive result in one call, so large graphs are often explored in Catalog Explorer first, then confirmed with SQL.
Exercise
You plan to drop the column main.sales.orders.discount_code. Write a query that lists the downstream tables and columns that read it, and explain why DISTINCT and target_table_full_name IS NOT NULL are used.
Show answer
SELECT DISTINCT targettablefullname, targetcolumnname FROM system.access.columnlineage WHERE sourcetablefullname = 'main.sales.orders' AND sourcecolumnname = 'discountcode' AND targettablefull_name IS NOT NULL; DISTINCT collapses the repeated rows written by each run of the same job. The IS NOT NULL filter removes reads that did not write to a table, such as ad hoc queries, so only real downstream dependencies remain.