Data Lineage: Tracing the Journey of Your Data

Learn how to implement data lineage for tracking data flow across systems, enabling impact analysis, debugging, and compliance.

published: reading time: 14 min read author: Geek Workbench updated: November 12, 2026
Quick Summary

Data lineage records selected relationships between source assets, transformations, and consumers. Its usefulness depends on coverage, freshness, and how each edge was captured; observed, inferred, and manual edges should be distinguishable. Use lineage to identify possible impact and investigation paths, then confirm them with owners and system evidence.

Data Lineage: Tracing the Journey of Your Data

When something goes wrong with a report, how do you trace the problem back to its source? When a compliance auditor asks where a particular number came from, can you answer? When you need to change a calculation, which downstream reports will be affected?

Data lineage records relationships between data sources, transformations, and downstream assets. Capture methods may see only part of a system, so lineage should show its source, coverage, and last update rather than imply that every path is known.

Why Lineage Matters

Lineage can support three common tasks:

Impact analysis: Before changing a calculation or column, use known downstream relationships to find assets and owners to review. Confirm dependencies with code, query logs, and teams when coverage is incomplete.

Root cause analysis: When a report changes unexpectedly, trace recorded upstream relationships to build an investigation path. Validate each hop against run history and source evidence.

Audit support: Lineage can contribute evidence about recorded data flows. It does not by itself prove completeness, correctness, authorization, or compliance.

Lineage reduces some manual tracing, but incomplete or stale metadata can miss dependencies. Treat the graph as evidence with known coverage rather than as an exhaustive map.

When to Use Lineage

Use Case Best Lineage Level Recommended Approach
Compliance and audit reporting Table or Column OpenLineage + data catalog
Impact analysis before schema changes Column Column-level graph database
Root cause investigation Column Column-level with transformation expressions
Debugging data quality issues Row Row-level with batch tracking
CI/CD validation of pipeline changes Table Automated ETL capture

Lineage is worth the overhead when any of these conditions hold:

  • Changes to shared datasets need impact review
  • Teams need to investigate freshness or quality incidents across multiple transformations
  • Audit processes require evidence about recorded data flows

When a lightweight inventory may be enough:

  • A small, short-lived project with no downstream consumers
  • A one-time transfer that has no continuing dependencies
  • A team cannot maintain automated capture yet; document the critical path and the known gaps instead

Levels of Lineage Granularity

Lineage can be captured at different levels of detail. Choose the least costly level that supports the investigation or change decision, and record what it does not cover.

Coverage, Confidence, and Provenance

Record how each relationship was created and when it was last refreshed. A practical status scheme is:

Status Meaning Example source
Observed Emitted by a running job or recorded execution event Instrumented pipeline run or query log
Inferred Parsed from code or a model dependency SQL parser or declared dbt ref()
Manual Entered by an owner and reviewed Spreadsheet, one-off load, or external process register
Missing A known asset or path has no captured relationship Uninstrumented job or unavailable source

Attach provenance, capture time, job/run identifier, and relevant code or schema version where available. Do not present inferred or manual relationships as execution evidence, and do not treat an absent edge as proof that a dependency does not exist.

Table-Level Lineage

Table-level lineage tracks which tables flow to which other tables. This is the simplest form and often sufficient for impact analysis.

-- Table-level lineage registry
CREATE TABLE table_lineage (
    lineage_id INT PRIMARY KEY AUTO_INCREMENT,
    source_table VARCHAR(200) NOT NULL,
    target_table VARCHAR(200) NOT NULL,
    etl_job_name VARCHAR(200),
    load_frequency VARCHAR(50),
    last_loaded TIMESTAMP,
    FOREIGN KEY (source_table) REFERENCES tables(table_id),
    FOREIGN KEY (target_table) REFERENCES tables(table_id)
);

-- Example records
INSERT INTO table_lineage (source_table, target_table, etl_job_name)
VALUES
    ('staging.customers', 'warehouse.dim_customer', 'customer_etl'),
    ('staging.orders', 'warehouse.fact_orders', 'order_etl'),
    ('warehouse.fact_orders', 'reports.daily_sales', 'sales_report_etl');

Table-level lineage answers: “Does this table depend on that table?” It does not answer: “Does this specific column depend on that specific column?”

Column-Level Lineage

Column-level lineage tracks dependencies at the column level. This is more detailed and enables more precise impact analysis.

-- Column-level lineage
CREATE TABLE column_lineage (
    lineage_id INT PRIMARY KEY AUTO_INCREMENT,
    source_table VARCHAR(200),
    source_column VARCHAR(100),
    target_table VARCHAR(200),
    target_column VARCHAR(100),
    transformation_type VARCHAR(50),  -- DIRECT, COMPUTED, AGGREGATED
    transformation_expression TEXT,
    FOREIGN KEY (target_table, target_column)
        REFERENCES columns(table_id, column_id)
);

Column-level lineage tells you that warehouse.customer_lifetime_value is computed from staging.orders.total_amount summed over staging.orders.customer_id.

Row-Level Lineage

Row-level lineage tracks individual records. This is more expensive to store but necessary for certain compliance use cases.

-- Row-level lineage (simplified)
CREATE TABLE row_lineage (
    lineage_id BIGINT PRIMARY KEY AUTO_INCREMENT,
    source_system VARCHAR(100),
    source_record_id VARCHAR(200),
    target_system VARCHAR(100),
    target_record_id VARCHAR(200),
    load_timestamp TIMESTAMP,
    batch_id VARCHAR(50)
);

Row-level lineage can answer: “Show me every record in the warehouse that was derived from this source record” or “What source records contributed to this specific output record?”

Capturing Lineage

Automated capture can reduce manual work, but it only covers configured integrations and supported operations. Keep a reviewed inventory of important paths that cannot be captured automatically.

ETL-Based Lineage Capture

Some platform integrations can emit lineage automatically. Verify the supported operations and version for the tools you run; see the Apache Spark documentation, dbt documentation, and OpenLineage project. References checked 2026-11-12.

# Pseudocode only: Spark does not expose this subclass as a built-in lineage API.
# Check the integration for the Spark version and deployment you run.
from pyspark import SparkConf
from pyspark.sql import SparkSession

class LineageCaptureSparkSession(SparkSession):
    """Spark session that captures lineage."""

    def __init__(self):
        super().__init__()
        self.lineage_tracker = LineageTracker()

    def _capture_read_operation(self, table_name):
        """Track when a table is read."""
        self.lineage_tracker.record_operation(
            operation_type='READ',
            source=(table_name, None),
            target=(self.current_job, self.current_output)
        )

    def _capture_write_operation(self, output_table):
        """Track when a table is written."""
        self.lineage_tracker.record_operation(
            operation_type='WRITE',
            source=(self.current_input, None),
            target=(output_table, None)
        )

    def _capture_transformation(self, expression):
        """Track column-level transformations."""
        self.lineage_tracker.record_operation(
            operation_type='TRANSFORM',
            source=(self.current_input, self.read_columns),
            target=(self.current_output, self.written_columns),
            expression=expression
        )

dbt Lineage

dbt can derive model dependencies from declared ref() relationships. Direct queries, external jobs, and dependencies outside the project need separate capture or documentation.

# dbt lineage is captured from model dependencies
# models/staging/stg_orders.sql
SELECT
    order_id,
    customer_id,
    order_date,
    total_amount
FROM raw.orders

# models/marts/fact_orders.sql
SELECT
    order_id,
    customer_id,
    order_date,
    total_amount
FROM {{ ref('stg_orders') }}

The dbt DAG represents declared project dependencies; it does not automatically include every external read or write in the surrounding system.

# Illustrative CLI query; confirm supported flags against the deployed dbt version.
dbt ls --output json | jq '.[] | select(.resource_type == "model")'

Change Data Capture Lineage

CDC events can carry lineage information through the pipeline.

{
  "event_type": "UPDATE",
  "source_system": "oracle_erp",
  "source_table": "orders",
  "source_record_id": "12345",
  "target_system": "snowflake",
  "target_table": "staging.orders",
  "timestamp": "2026-03-27T10:00:00Z",
  "changes": {
    "status": { "old": "pending", "new": "shipped" },
    "shipped_date": { "old": null, "new": "2026-03-27" }
  },
  "lineage_metadata": {
    "batch_id": "batch-2026-03-27-001",
    "etl_job": "orders_cdc_job"
  }
}

Lineage Standards

Several standards exist for representing lineage data.

OpenLineage

OpenLineage defines events for jobs, runs, and datasets. The JSON below is illustrative rather than a complete, version-pinned event; use the schema URL and fields supported by the emitter and receiver you deploy. See the OpenLineage documentation and validate against the selected schema version.

{
  "eventType": "COMPLETE",
  "eventTime": "2026-03-27T10:00:00Z",
  "run": {
    "runId": "run-123"
  },
  "job": {
    "namespace": "warehouse",
    "name": "fact_orders_etl"
  },
  "inputs": [
    {
      "namespace": "staging",
      "name": "staging.orders",
      "facets": {
        "schema": {
          "fields": [
            { "name": "order_id", "type": "BIGINT" },
            { "name": "customer_id", "type": "INT" }
          ]
        }
      }
    }
  ],
  "outputs": [
    {
      "namespace": "warehouse",
      "name": "warehouse.fact_orders",
      "facets": {
        "outputStatistics": {
          "rowCount": 1000000
        }
      }
    }
  ]
}

OpenLineage documents integrations for selected pipeline tools. Check its current integration list and compatibility notes for the exact tool and release you use.

Data Catalog Integration

Catalogs can display lineage from supported integrations, but connector coverage and event fields vary. Confirm the deployed catalog and emitter versions before relying on specific edges.

# Illustrative pseudocode, not a version-pinned Atlas client.
# Check the current Atlas API and client documentation before adapting it.
from atlas_client import AtlasClient

atlas = AtlasClient('http://atlas:21000', ('admin', 'admin'))

def publish_lineage(atlas, lineage_event):
    """Publish lineage event to Atlas."""

    # Create Atlas lineage record
    guid_map = atlas.create_entities([
        {
            'typeName': 'DataSet',
            'attributes': {
                'qualifiedName': lineage_event['target_table'],
                'name': lineage_event['target_table'].split('.')[-1],
                'description': f"Loaded from {lineage_event['source_table']}"
            }
        }
    ])

    # Create lineage relationship
    atlas.create_lineage({
        'guid': guid_map[0],
        'lineageDirection': 'OUTPUT',
        'lineageRelations': [{
            'guid': get_guid_for_source(lineage_event['source_table']),
            'lineageType': 'INPUT'
        }]
    })

Visualizing Lineage

flowchart TB
    subgraph "Source Systems"
        S1["Oracle ERP\nstaging.orders"]
        S2["Salesforce CRM\nstaging.customers"]
        S3["Shopify\nstaging.products"]
    end
    subgraph "ETL / Transformation Layer"
        E1["dbt: stg_orders"]
        E2["dbt: dim_customer"]
        E3["dbt: fact_orders"]
    end
    subgraph "Warehouse"
        W1["warehouse.dim_customer"]
        W2["warehouse.fact_orders"]
    end
    subgraph "Reporting"
        R1["reports.daily_sales"]
        R2["reports.customer360"]
    end
    S1 --> E1
    S2 --> E1
    S2 --> E2
    S3 --> E3
    E1 --> E3
    E1 --> E2
    E2 --> W1
    E3 --> W2
    W1 --> R2
    W2 --> R1
    W2 --> R2

A lineage graph is only useful if you can explore it visually.

Graph Databases for Lineage

Graph databases like Neo4j are natural fits for lineage storage.

-- Query lineage downstream of a table
MATCH (source:Table {name: 'staging.orders'})
MATCH (source)-[:DEPENDS_ON*]->(downstream)
RETURN downstream

-- Query lineage upstream of a table
MATCH (target:Table {name: 'reports.daily_sales'})
MATCH (upstream)-[:DEPENDS_ON*]->(target)
RETURN upstream

-- Find paths between two tables
MATCH path = (a:Table)-[:DEPENDS_ON*]->(b:Table)
WHERE a.name = 'staging.customers' AND b.name = 'reports.customer360'
RETURN path

Lineage UI

Build or buy a lineage UI that lets users explore the graph.

Key features:

  • Search: Find any table or column
  • Upstream view: See what feeds into a table
  • Downstream view: See what a table feeds into
  • Filter by system: Show only certain systems in the graph
  • Depth control: Limit how many hops to display
  • Column drill-down: Show column-level dependencies when needed

Lineage Use Cases

Impact Analysis

def impact_analysis(table_name, lineage_graph):
    """Find all downstream dependencies of a table."""

    downstream = set()

    def traverse(node):
        for child in lineage_graph.get_children(node):
            downstream.add(child)
            traverse(child)

    traverse(table_name)
    return downstream

# Before dropping a column:
impacted_reports = impact_analysis('warehouse.fact_orders', lineage_graph)
print(f"Dropping this column affects: {impacted_reports}")

Root Cause Analysis

def root_cause_analysis(report_name, expected_value, actual_value,
                        lineage_graph):
    """Trace unexpected values back to source."""

    # Get all upstream tables
    upstream = get_upstream_tables(report_name, lineage_graph)

    # Check each upstream table for anomalies
    for table in upstream:
        anomalies = check_for_anomalies(
            table,
            date_range=get_report_date_range(report_name)
        )

        if anomalies:
            print(f"Potential issue in {table}:")
            for anomaly in anomalies:
                print(f"  - {anomaly}")

Compliance Evidence

def generate_compliance_report(table_name, date_range, lineage_graph):
    """Generate lineage evidence for audit."""

    upstream = get_upstream_tables(table_name, lineage_graph)

    report = {
        'report_table': table_name,
        'date_range': date_range,
        'lineage': [],
        'data_quality_metrics': {}
    }

    for table in upstream:
        record = {
            'table': table,
            'source_system': get_source_system(table),
            'last_refreshed': get_last_refresh_time(table),
            'transformation_rules': get_transformations(table),
            'validation_results': get_validation_results(table, date_range)
        }
        report['lineage'].append(record)

    return report

Challenges with Lineage

Coverage

Legacy systems, SQL run manually, notebooks, external services, and direct writes may not emit lineage. Record these as manual or missing paths and include an owner. A clean graph only describes the edges that were captured.

Query and storage cost

Column and row lineage can create more data and more expensive traversals than table lineage. Measure the queries users need, cap traversal depth where appropriate, and use summaries or precomputed paths when interactive exploration is too slow. Choose a graph store only if the measured query pattern justifies it.

Freshness

Schema changes, job refactors, and connector failures can leave stale edges. Store capture time and run status, and show users when a relationship was last confirmed. Make lineage publication part of the pipeline’s observable outcome.

Building a Lineage Program

Start with what you can automate and expand.

  1. Instrument ETL jobs. Use OpenLineage or similar standards to capture lineage automatically from your main ETL platforms.

  2. Integrate with data catalog. Push lineage to a catalog that provides search and visualization.

  3. Capture dbt lineage. If you use dbt, export the model DAG automatically.

  4. Document critical paths manually. For systems that cannot be instrumented, document critical lineage paths manually.

  5. Build use cases. The value of lineage is in the use cases. Build impact analysis and root cause analysis tools that make lineage useful.

Lineage Trade-Offs

Dimension Table-Level Column-Level Row-Level
Storage overhead Low Medium High
Query performance Fast Medium Slow
Precision of impact analysis Low High Very high
Implementation complexity Low Medium High
Compliance suitability Basic audits Regulatory audits Full audit trails
Maintenance cost Low Medium High

Example: Investigating a Broken Report

Suppose a sales report starts returning null regions after a dimension column is renamed. The lineage graph shows the report depends on dim_customer.region, so the analyst traces downstream consumers from that dimension and identifies the report and its owner. The team then checks the edge provenance: a dbt dependency is inferred from model code, while a dashboard edge is observed from a catalog or BI integration.

Before changing or restoring the column, the team checks the last successful run, the deployed model version, and the BI query or dashboard metadata. If a manual export or direct SQL job is known to exist but has no captured edge, it stays on the investigation checklist. This example is hypothetical; the steps depend on which systems emit lineage and how recently it was refreshed.

The investigation produces an impact list, not a guarantee. Owners confirm affected consumers, and the change is tested before rollout. If a new job bypassed the instrumented path, add it to the inventory or capture its events before treating future impact reports as complete.

Lineage Observability Hooks

Track these metrics to keep lineage trustworthy:

-- Lineage coverage: % of jobs with lineage captured
SELECT
    job_name,
    CASE
        WHEN lineage_last_updated IS NOT NULL
        AND lineage_last_updated > last_job_run - INTERVAL '1 day'
        THEN 'COVERED'
        ELSE 'MISSING'
    END AS lineage_status
FROM etl_job_registry;

-- Detect orphaned tables: tables with no upstream lineage
SELECT
    table_name,
    last_loaded,
    last_data_refresh
FROM table_registry
WHERE table_name NOT IN (
    SELECT DISTINCT target_table FROM table_lineage
);

-- Verify column lineage completeness
SELECT
    target_table,
    target_column,
    COUNT(DISTINCT source_table) AS upstream_sources
FROM column_lineage
GROUP BY target_table, target_column
HAVING COUNT(DISTINCT source_table) = 0;

Log every pipeline run: job name, run ID, start/end timestamps, row counts before and after, and whether lineage was successfully published. Alert when a pipeline run lacks an expected lineage event, a relationship is older than its agreed freshness window, or known asset inventory and captured edges diverge.

Lineage Anti-Patterns

Partial lineage hidden from users. Show captured coverage and missing paths so users can judge whether the graph is enough for an impact or root-cause decision.

Lineage without use cases. Maintaining lineage that nobody uses is a resource drain. Build the use cases first (impact analysis, root cause tools), then instrument to serve those use cases.

Graph schema mismatches production schema. The lineage graph shows a table that was dropped 6 months ago. The graph was populated once and never updated. Treat lineage as a living system, not a one-time project.

Column-level lineage on systems that only need table-level. Column-level lineage is expensive to store and query. If your compliance requirements only need table-level, save the overhead.

Data Lineage Quick Recap

  • Lineage tracks data flow from source to destination at table, column, or row level.
  • Table-level answers “which tables depend on which.” Column-level answers “which columns derive from which.” Row-level answers “which records came from which.”
  • Capture relationships at the granularity required by the use case.
  • Mark edges as observed, inferred, manual, or missing, with provenance and refresh time.
  • Use OpenLineage or platform-specific integrations when they cover the pipeline and version in use.
  • Keep a reviewed inventory for manual or external paths, and test impact lists with asset owners.
  • Treat lineage as evidence for investigation, not proof that no other dependency exists.

For decision rights and policy, see Data Governance. For quality ownership and response, see Data Quality. For discovery and asset metadata, see Data Catalog.

Category

Related Posts

Data Catalog: Organizing and Discovering Data Assets

Learn how a data catalog supports asset discovery, metadata curation, ownership, freshness, lineage, and access requests across data platforms.

#data-engineering #data-catalog #metadata

Audit Trails: Building Complete Data Accountability

Trace an order across API, outbox, payment, and shipping. Define event fields and a correlation query, then weigh access, integrity, retention, and deletion.

#data-engineering #audit #audit-trails

Data Contracts: Establishing Reliable Data Agreements

Learn how to implement data contracts between data producers and consumers to ensure quality, availability, and accountability.

#data-engineering #data-contracts #data-quality