sqlmesh-openlineage
OpenLineage integration for SQLMesh. Automatically emits lineage events to Marquez or any OpenLineage-compatible backend.
Features
- Table-level lineage: Track which models depend on which upstream models
- Column-level lineage: Track which columns flow from source to destination
- Schema capture: Column names and types for each model
- Execution stats: Duration, rows processed, bytes processed
- Per-model events: START/COMPLETE/FAIL events for each model evaluation
Installation
pip install sqlmesh-openlineage
Or with uv:
uv add sqlmesh-openlineage
Quick Start (CLI Users)
Note: This package requires Python-based SQLMesh configuration (config.py), not YAML configuration.
Add this to your config.py:
import sqlmesh_openlineage
sqlmesh_openlineage.install(
url="http://localhost:5000",
namespace="my_project",
# api_key="...", # optional
)
from sqlmesh.core.config import Config
config = Config(
# ... your existing config
)
Then run sqlmesh run as normal. OpenLineage events will be emitted for each model evaluation.
Environment Variables
You can also configure via environment variables:
export OPENLINEAGE_URL=http://localhost:5000
export OPENLINEAGE_NAMESPACE=my_project
export OPENLINEAGE_API_KEY=... # optional
Then in config.py:
import sqlmesh_openlineage
sqlmesh_openlineage.install() # reads from env vars
How It Works
This package uses SQLMesh's set_console() API to inject a custom Console wrapper. The wrapper intercepts per-snapshot lifecycle events and emits corresponding OpenLineage events:
STARTevent when a model evaluation beginsCOMPLETEevent when evaluation succeeds (includes execution stats)FAILevent when evaluation fails or audits fail
Events Emitted
| SQLMesh Event | OpenLineage Event | Data Included |
|---|---|---|
| Model evaluation start | RunEvent(START) | Input datasets, output dataset with schema, column lineage |
| Model evaluation success | RunEvent(COMPLETE) | Execution stats (rows, bytes, duration) |
| Model evaluation failure | RunEvent(FAIL) | Error message |
| Audit failure | RunEvent(FAIL) | Audit failure details |
Column-Level Lineage
The integration automatically extracts column-level lineage using SQLMesh's built-in lineage analysis. For example, if you have:
-- customers.sql
SELECT customer_id, name, email FROM raw_customers
-- customer_summary.sql
SELECT
c.customer_id,
c.name as customer_name,
COUNT(o.order_id) as total_orders
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.name
The lineage will show that customer_summary.customer_name traces back to customers.name.
Testing with Marquez
# Start Marquez (requires Docker)
docker compose up -d
# Configure and run SQLMesh
export OPENLINEAGE_URL=http://localhost:5001
sqlmesh run
# View lineage at http://localhost:3000
Development
# Install dependencies
uv sync --dev
# Run tests (unit + integration)
uv run pytest tests/ -v
# Run Marquez integration test (requires Docker)
docker compose up -d
uv run pytest tests/test_marquez_integration.py -v -s
docker compose down
License
MIT
Metadata
Release files for sqlmesh-openlineage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sqlmesh_openlineage-0.1.0.tar.gz | 156.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sqlmesh_openlineage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 166.8 kB
Release files / sqlmesh_openlineage-0.1.0.tar.gz
| Download URL | sqlmesh_openlineage-0.1.0.tar.gz |
|---|---|
| Size | 156.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d5e54ace4678db33f742d80bdeefb66a285b71c44af88bc5af2771c5122247e
|
|
BLAKE2b-256 checksum How to use checksums |
6a4099aa687e7680c4b659b990c2eaba3d614d040c3afa3c6ee8d7f80bc914d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.6
|
Release files / sqlmesh_openlineage-0.1.0-py3-none-any.whl
| Download URL | sqlmesh_openlineage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e101ae6ecc1732def8ae7c65e973f28318ca642db76c2c3f80d0643e6277b4e1
|
|
BLAKE2b-256 checksum How to use checksums |
dfb2c6658d101e92eeaf598bed6049ec375059be39bd3a5e8efebacaebf22295
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.6
|
Security for sqlmesh-openlineage 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.