# What Is Column-Level Data Lineage? Explained With SQL Examples

> Column-level lineage traces each output column to the source columns it was built from. Learn how it works with SQL examples, its limits and a free tool.

Page: https://datautility.in/blog/what-is-column-level-data-lineage-with-sql-examples
This is the Markdown copy of the page. The tool itself runs in the browser: your files are processed on your own device and are not uploaded.

Published 2026-11-17 · Analyze & protect · column level data lineage examples, what is column level lineage, column lineage sql, column level lineage explained, column lineage example, trace a column in sql

Table-level lineage tells you that one table feeds another. Column-level lineage goes a step further and tells you which exact columns went into which output column, and what was done to them on the way. It is the level you need when a number is wrong or a sensitive field has to be tracked. Here is how it works, using small SQL examples you can follow.

Open the tool: [SQL Column Lineage Tool](https://datautility.in/sql-column-lineage-tool)

## The definition

Column-level data lineage records, for each column in a table or view, the source columns it is derived from and the transformation applied. It is a set of links between columns, not just between tables.

## Example 1: a copied column

```sql
create view customers_clean as
select id as customer_id, email
from raw.customers;
```

customers_clean.customer_id comes from raw.customers.id. The column was renamed but not changed, so lineage marks it as copied. customers_clean.email comes from raw.customers.email, also copied.

## Example 2: a calculated column

```sql
create view order_totals as
select order_id, quantity * unit_price as line_total
from raw.order_items;
```

line_total is built from two source columns, quantity and unit_price, combined by multiplication. Column lineage records both links and the expression, so you can see it is calculated rather than copied.

## Example 3: an aggregate

```sql
create table revenue as
select customer_id, sum(line_total) as total_revenue
from order_totals
group by customer_id;
```

total_revenue is built from line_total through SUM. Following it upstream: total_revenue, then line_total, then quantity and unit_price in raw.order_items. That four-hop answer is exactly what a person needs when asked "what makes up this revenue figure?".

## Example 4: a CASE expression

```sql
select order_id,
  case when country = 'US' then amount else amount * fx_rate end as amount_usd
from raw.orders;
```

amount_usd depends on country, amount and fx_rate. Even though only some rows use fx_rate, the column depends on all three, so all three appear in its lineage.

## Where column lineage comes from

It can be collected at run time or read from code. Reading from SQL means parsing each statement to work out which source columns appear in each output expression, following aliases, subqueries and CTEs. It needs only the SQL text.

## Why it is harder than table lineage

Several things make column lineage tricky and explain why every tool calls it best effort:

- SELECT *: the column list is only known if the source table is defined somewhere you can see.

- Dynamic SQL: queries built from strings at run time cannot be analysed from the source text.

- Macros and templates: Jinja that generates columns means the SQL text is not the final SQL.

- Unusual syntax: vendor-specific functions can hide which columns are used.

A trustworthy tool tells you when it could not read something instead of silently drawing a partial picture.

## What you can do with it

- Debug a wrong figure by following it upstream.

- Check every column affected by renaming or retyping a source column.

- Find where a sensitive column such as an email or ID travels.

- Review a change and confirm only the expected columns are affected.

## Try it on your own SQL

Drop your SQL files, ZIP or dbt models folder into the [column-level lineage tool](https://datautility.in/sql-column-lineage-tool), open the Columns tab, choose a table and click a column. You will see the source columns on one side and dependent columns on the other, with each link marked copied or calculated. It runs in your browser, so the files are not uploaded.

## How to read a column lineage result

A column lineage view usually has three parts. The selected column in the middle, the columns it comes from on one side, and the columns that depend on it on the other. Read it like a sentence: "total_revenue comes from line_total, which comes from quantity and unit_price, and is used by the monthly_summary view".

Pay attention to two details. First, whether each link copies or calculates the column, because calculations are where meaning changes. Second, how many steps away a dependant is. A column two or three hops downstream is easy to forget during a change.

## Column lineage and sensitive data

Column lineage is also a privacy tool. If email is a sensitive column, you can click it in a lineage tool and see every column derived from it, including ones where it was hashed, concatenated or truncated. That tells you which downstream tables inherit the sensitivity and need the same access controls. It does not tell you whether the data in them is actually protected, only where it flows.

## Next steps

If you are weighing granularity, read [table-level vs column-level data lineage](https://datautility.in/blog/table-level-vs-column-level-data-lineage). To apply column lineage across a transformation chain, see [how to track column dependencies across SQL transformations](https://datautility.in/blog/track-column-dependencies-across-sql-transformations). For dbt users, read [column-level lineage for analytics engineers](https://datautility.in/blog/dbt-column-level-lineage-from-your-sql-models).

## How to use the SQL Column Lineage Tool: step by step

1. Pick one calculated column in your SQL.
2. Write down the source columns in its expression.
3. Confirm the result in the Columns tab of a lineage tool.

## When to use the SQL Column Lineage Tool

- Learn column lineage from examples
- Debug a calculated column
- Check a sensitive field's path
- Explain column lineage to a team

## Example

Input:

```
CREATE TABLE fct_sales AS SELECT quantity * unit_price AS revenue FROM …
```

Output:

```
revenue ← raw.order_items.quantity, raw.order_items.unit_price
```

## Frequently asked questions

### What is column-level data lineage?
It records, for each column, which source columns it is built from and what transformation was applied, so you can trace a value back to its origin.

### How is column lineage read from SQL?
By parsing each statement and following which source columns appear in each output expression, through aliases, subqueries and CTEs.

### Is column-level lineage always complete?
No. It is best effort. SELECT * without known columns, dynamic SQL and macros that generate columns cannot be fully traced.

### Does it need a database connection?
Not when read from SQL text. The files alone are enough.

Tip: Include the CREATE TABLE statements for raw tables so that SELECT * can be expanded into real columns.

## Related tool pages

- [SQL Lineage Analyzer for a Folder of SQL Files](https://datautility.in/sql-lineage-analyzer): Upload a folder of SQL files or a dbt project and get table and column lineage across every file, a run order and impact analysis. Free, runs in your browser.
- [dbt Lineage Viewer for Your SQL Models](https://datautility.in/dbt-lineage-viewer): Drop your dbt models folder and see the lineage graph from sources through staging to marts, with column links. No dbt run, no warehouse. Free, private.
- [SQL File Dependency Analyzer](https://datautility.in/sql-file-dependency-analyzer): Find out which SQL file must run before which, from the tables each file creates and reads. Get a run order, circular dependencies and tables nothing uses.
- [SQL Impact Analysis: What Breaks If a Table Changes](https://datautility.in/sql-impact-analysis): Pick a table and see everything downstream that depends on it, and every upstream source it is built from. Works across a whole folder of SQL files, free.
- [SQL File Lineage Tool](https://datautility.in/sql-file-lineage): Free SQL file lineage tool: drop a folder of .sql files and see which file feeds which table, column by column. Nothing is uploaded.
- [SQL Query Visualizer](https://datautility.in/sql-query-visualizer): Free SQL query visualizer: paste a query or drop SQL files and see tables, joins and columns as a clear diagram. Runs in your browser, no upload.

## Also try

- [Table-level vs column-level lineage](https://datautility.in/blog/table-level-vs-column-level-data-lineage)
- [Track column dependencies](https://datautility.in/blog/track-column-dependencies-across-sql-transformations)
- [Trace PII through SQL lineage](https://datautility.in/blog/trace-pii-through-sql-lineage)

## More guides

- [Data Profiler: Check Data Quality Before You Use It](https://datautility.in/blog/data-profiler-check-data-quality)
- [Compare Two CSV or Excel Files: Find Added, Removed and Changed Rows](https://datautility.in/blog/compare-two-csv-files-find-differences)
- [Data Masking: Hide Emails, Phones and Names Before Sharing](https://datautility.in/blog/data-masking-hide-emails-phones-pii)
