Data Lineage
Data Lineage
Tracking data flow. The path from the source to the final result.
Data Lineage
Tracking data flow. The path from the source to the final result.
Data lineage is a technology that tracks the creation, movement, and transformation of data to visualize the flow from the original source to the final result. It makes it possible to transparently see where data came from, how it was transformed, and where it went.
It is an essential capability for data governance, regulatory compliance (GDPR, SOX, HIPAA), impact analysis, and debugging. When a schema change or data quality issue occurs, it lets you immediately identify which downstream systems are affected, greatly shortening incident response time.
OpenLineage has become established as the industry-standard protocol, and major data tools such as Airflow, Spark, and dbt automatically emit OpenLineage events. Platforms such as DataHub, Marquez, and Apache Atlas collect and visualize lineage graphs.
Column-Level Lineage tracks even which transformations an individual field went through to be created. Through SQL parsing, it automatically extracts mapping relationships between fields in SELECT, JOIN, and GROUP BY operations.
# OpenLineage 기반 데이터 리니지 추적
from openlineage.client import OpenLineageClient
from openlineage.client.run import (
RunEvent, RunState, Run, Job,
InputDataset, OutputDataset
)
from openlineage.client.facet import (
SqlJobFacet, SchemaDatasetFacet, SchemaField,
ColumnLineageDatasetFacet
)
import uuid
from datetime import datetime
# OpenLineage 클라이언트 초기화
client = OpenLineageClient(url="http://marquez:5000")
namespace = "data_platform"
# Job과 Run 정의
job = Job(namespace=namespace, name="daily_customer_aggregation")
run = Run(runId=str(uuid.uuid4()))
# 리니지 이벤트 발행: 작업 시작
start_event = RunEvent(
eventType=RunState.START,
eventTime=datetime.now().isoformat(),
job=job,
run=run,
inputs=[
InputDataset(
namespace=namespace,
name="bronze.orders",
facets={
"schema": SchemaDatasetFacet(fields=[
SchemaField(name="order_id", type="STRING"),
SchemaField(name="customer_id", type="STRING"),
SchemaField(name="amount", type="DECIMAL")
])
}
),
InputDataset(namespace=namespace, name="bronze.customers")
],
outputs=[
OutputDataset(
namespace=namespace,
name="gold.customer_metrics",
facets={
"columnLineage": ColumnLineageDatasetFacet(fields={
"total_revenue": {
"inputFields": [
{"namespace": namespace,
"name": "bronze.orders",
"field": "amount"}
],
"transformationType": "AGGREGATION",
"transformationDescription": "SUM(amount)"
}
})
}
)
],
producer="https://github.com/company/data-pipeline"
)
client.emit(start_event)
# 작업 완료 이벤트
complete_event = RunEvent(
eventType=RunState.COMPLETE,
eventTime=datetime.now().isoformat(),
job=job, run=run
)
client.emit(complete_event)
print(f"Lineage event emitted for run: {run.runId}")
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free