FullStack AI Hub
Studio
lesson depth
Mastery
not started · 0%

Data Governance & Lineage (OpenLineage)

End-to-end data provenance tracing, column-level lineage, and compliance auditing.

Freshness: current•15 min read•Data Engineering and Databases

Key Learning Outcomes

  • ✓Trace column-level data lineage across complex ETL pipelines using OpenLineage
  • ✓Enforce compliance audit trails for sensitive data transformations
Full Technical Reference Document

Mental model

When an executive dashboard number suddenly diverges or a GDPR deletion request requires finding every downstream AI feature table storing customer PII, manually reading 200 Spark scripts, dbt models, and Airflow DAGs fails immediately. OpenLineage establishes a vendor-neutral open standard (aligned conceptually with W3C PROV provenance graphs) where data engines themselves—Spark, Airflow, dbt, Flink, Trino—emit real-time runtime RunEvent telemetry during execution (START -> RUNNING -> COMPLETE/FAIL). Instead of brittle static SQL scraping alone, OpenLineage records immutable Job, Run, and Dataset entities enriched with typed JSON Facets covering table schemas, column-level provenance, row counts, data quality assertions, and Git code versions inside lineage catalogs such as Marquez, DataHub, or OpenMetadata.

Orchestrator / Engine Starts Execution (Run ID)
Emit OpenLineage RunEvent + Input/Output Datasets
Attach Schema, ColumnLineage & DQ Facets
Persist Versioned Provenance Graph (Catalog)
Trace Blast Radius & Compliance Audit
Conceptual teaching model synthesized from:openlineage-spec,w3c-prov-overview

Theory

OpenLineage cleanly solves the fragmented metadata puzzle through an extensible 3-entity core model paired with composable Facets:

Core Entity / ConceptIdentity GranularityStandard OpenLineage Facets AttachedPractical Engineering Value
Job (namespace + name)Logical transformation definition (e.g. dbt://analytics.daily_orders)SqlJobFacet, SourceCodeLocationFacet (Git SHA + PR URL!)Tracks exact SQL/Spark logic across deployments cleanly
Run (runId UUID)Specific execution instance of a Job (START, COMPLETE, FAIL)NominalTimeRunFacet, ParentRunFacet (links Airflow task -> Spark job -> SQL child!)Separates yesterday's corrupted run from today's fixed rerun
Dataset (namespace + name)Physical input/output table or topic (postgres://db/public.users, s3://lake/orders)SchemaDatasetFacet, ColumnLineageDatasetFacet, DataQualityMetricsInputDatasetFacet, SymlinksDatasetFacetPinpoints exact upstream breaking column changes before dashboards crash!

Runtime Lineage vs. Static SQL Scraping—And Column-Level Impact Analysis

Traditional metadata crawlers parse static Git SQL files overnight, missing runtime truth when dynamic Airflow Jinja parameters inject partition dates, views alias Iceberg snapshots, or external Spark jobs bypass SQL altogether (Symlinks mapping Hive Metastore names cleanly to physical S3 URIs!). Emitting live RunEvent hooks from execution listeners captures what actually ran (nominalTime), attaches parent-child correlation (ParentRunFacet stitching an Airflow DAG -> Spark Operator -> Trino table load into one unified graph), and propagates Column-Level Lineage Facets (IDENTITY, TRANSFORMATION, AGGREGATION) automatically across joins (orders.subtotal_cents -> rev_daily.gross_usd). When an engineering squad wants to rename or drop a column in a production PostgreSQL table ingested by Debezium into an AI RAG feature pipeline, querying downstream OpenLineage graphs highlights every impacted downstream dbt model, Feast feature view, and training dataset cleanly inside CI pull requests before breaking schemas merge!

python
from datetime import UTC, datetime
import uuid
import requests
​
def emit_openlineage_complete_event(
endpoint: str,
run_id: str,
job_name: str,
input_namespace: str,
input_name: str,
output_name: str,
) -> int:
# W3C PROV / OpenLineage compliant RunEvent linking inputs, outputs, and column lineage facets
event = {
"eventType": "COMPLETE",
"eventTime": datetime.now(UTC).isoformat(),
"run": {
"runId": run_id,
"facets": {
"processing_engine": {"version": "3.5.0", "name": "spark"},
},
},
"job": {"namespace": "prod-etl", "name": job_name},
"inputs": [{"namespace": input_namespace, "name": input_name}],
"outputs": [
{
"namespace": "lakehouse://warehouse",
"name": output_name,
"facets": {
"schema": {
"_producer": "https://github.com/OpenLineage/OpenLineage",
"_schemaURL": "https://openlineage.io/spec/facets/1-0-0/SchemaDatasetFacet.json",
"fields": [
{"name": "tenant_id", "type": "STRING"},
{"name": "total_tokens", "type": "BIGINT"},
],
},
"columnLineage": {
"_producer": "https://github.com/OpenLineage/OpenLineage",
"_schemaURL": "https://openlineage.io/spec/facets/1-2-0/ColumnLineageDatasetFacet.json",
"fields": {
"total_tokens": {
"inputFields": [
{"namespace": input_namespace, "name": input_name, "field": "token_count"}
],
"transformationType": "AGGREGATION",
"transformationDescription": "SUM(token_count)",
}
},
},
},
}
],
"producer": "https://acme.internal/etl-runner/1.0",
"schemaURL": "https://openlineage.io/spec/2-0-2/OpenLineage.json",
}
resp = requests.post(f"{endpoint}/api/v1/lineage", json=event, timeout=5)
return resp.status_code

Keep lineage transport non-blocking / asynchronous (HTTP batch or Kafka topic backed by retry buffers): failure of the metadata backend (Marquez/DataHub) must never abort critical revenue ETL jobs!

Alternatives and trade-offs

  • Runtime OpenLineage Listeners (Spark, Airflow, dbt, Flink) -> Catalog (Marquez / DataHub / OpenMetadata): Captures live dynamic runtime parameters, real failed vs succeeded run boundaries, data-quality test facets, and unified cross-engine dependency graphs cleanly; demands deploying listener plugins across engines and storing noisy high-frequency run history cleanly with retention compaction.
  • dbt Docs + Manifest Graph Only: Built-in, zero extra infrastructure if 100% of your transformations stay inside warehouse SQL via dbt—blind cleanly to upstream Debezium/Airflow ingestion, Python ML notebooks, Feast feature stores, and Spark pipelines feeding dbt!
  • Static AST SQL Parsing Crawlers (e.g., SQLGlot CI bots): Helpful for instant pre-merge CI impact warnings before code runs in production, best combined alongside live OpenLineage telemetry rather than replacing execution audit trails.

Failure modes and misconceptions

  1. Inconsistent Dataset Namespace/Name Canonicalization ("Phantom Duplicate Tables"): If Airflow records postgres://db-prod:5432/analytics.orders, dbt emits postgres://10.4.2.9/analytics.public.orders, and Spark emits s3a://lake/orders, catalog graphs fail to connect upstream producers to downstream consumers cleanly! Standardize Dataset naming conventions + SymlinksDatasetFacet strictly across all integrations.
  2. Synchronous Lineage Emission Crashing ETL Jobs When Metadata Store Restarts: Making critical Airflow DAGs call blocking HTTP lineage posts without timeouts or failure isolation turns a minor DataHub outage into production billing pipeline downtime. Emit OpenLineage events cleanly to Kafka or non-blocking async HTTP handlers with short timeouts and fail-open error logging.
  3. Collecting Infinite Per-Partition Run History Without Catalog Compaction / Retention: Micro-batch Spark jobs emitting START/COMPLETE events every 30 seconds generate millions of bloated RunEvent JSON rows per month unless catalogs compact historic run payloads and deduplicate static unchanged schema facets.
  4. Treating Table-Level Lineage as Sufficient for Schema Changes & PII Governance: Knowing table_A -> table_B doesn't reveal whether dropping table_A.email_hash breaks downstream table_B when table_B only actually reads table_A.order_total! Enable column-level lineage facets (ColumnLineageDatasetFacet) and classification tags cleanly for accurate impact analysis.
Reflect before revealing the guide

Decision scenario

Your data platform ingests PostgreSQL tables via Debezium/Airflow into Spark Iceberg lakes, transforms analytical cubes with dbt, and feeds ML training tables—recently suffering two multi-hour outages after an upstream database engineer dropped an "unused" column still consumed three hops downstream. Instrument Airflow, Spark (openlineage-spark), Trino, and dbt-ol to emit OpenLineage RunEvents asynchronously over Kafka into a central metadata catalog (DataHub/OpenMetadata) enforcing strict canonical dataset naming (<scheme>://<cluster>/<db>.<schema>.<table>) + SymlinksDatasetFacet, enable ColumnLineageDatasetFacet alongside DataQualityAssertionsDatasetFacet on every run, link orchestrator-to-engine spans via ParentRunFacet, and add a CI schema-check bot querying downstream column dependencies before approving breaking DDL pull requests.

Learning outcomes

  • Explain OpenLineage's three-entity provenance model (Job, Run, Dataset) and composable Facet architecture aligned with W3C PROV.
  • Contrast runtime OpenLineage event emission against static SQL AST crawlers and connect orchestrators cleanly via ParentRunFacet.
  • Eliminate broken lineage joins using canonical dataset URIs and SymlinksDatasetFacet while preserving ETL uptime via non-blocking emission.
  • Leverage column-level lineage graphs and data-quality facets for automated breaking-change impact checks and GDPR PII audits.

Trade-offs

Adopting OpenLineage unifies fragmented cross-engine observability, root-cause tracing, and regulatory PII auditing onto one open standard, at the engineering cost of dataset-naming standardization across engines, metadata catalog operation, and async run-history compaction.

Prerequisites & Related Concepts (3)

Private notes

0 words
Recommended Free Track
Free · Verifiable Credential

FS-201Production LLM Engineer

Design an observable full-stack LLM product from capability validation through interfaces retrieval evaluation security and operations.

37 concepts~35h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.

Next