|
| 1 | +# superset-openlineage |
| 2 | + |
| 3 | +OpenLineage integration for Apache Superset, shipped in the Stackable Superset |
| 4 | +image. It emits OpenLineage events when SQL Lab queries run and when dashboard |
| 5 | +charts fetch data. |
| 6 | + |
| 7 | +It is **config-only**: no changes are made to the Superset source tree, and the |
| 8 | +plugin stays completely inert unless it is explicitly enabled in |
| 9 | +`superset_config.py`. The package is installed into the image (see the |
| 10 | +`superset/Dockerfile` build stage), but activation is left to the operator/admin. |
| 11 | + |
| 12 | +## Enable it |
| 13 | + |
| 14 | +Add the following to `superset_config.py`: |
| 15 | + |
| 16 | +```python |
| 17 | +from superset_openlineage import ( |
| 18 | + build_query_logger, |
| 19 | + OpenLineageEventLogger, |
| 20 | + init_app, |
| 21 | +) |
| 22 | + |
| 23 | +QUERY_LOGGER = build_query_logger() |
| 24 | +EVENT_LOGGER = OpenLineageEventLogger() |
| 25 | + |
| 26 | +# Registers a teardown_request that clears the request-scoped stash |
| 27 | +# (required to avoid cross-request lineage mis-attribution on reused workers). |
| 28 | +def FLASK_APP_MUTATOR(app): |
| 29 | + init_app(app) |
| 30 | +``` |
| 31 | + |
| 32 | +## Configure the transport |
| 33 | + |
| 34 | +Point the client at a lineage backend with standard OpenLineage configuration |
| 35 | +(environment variables or `openlineage.yml`): |
| 36 | + |
| 37 | +```bash |
| 38 | +export OPENLINEAGE_URL=http://marquez:5000 |
| 39 | +export OPENLINEAGE_API_KEY=<token> # optional |
| 40 | +# or set OPENLINEAGE_DISABLED=true to turn emission off entirely |
| 41 | +``` |
| 42 | + |
| 43 | +## Plugin settings |
| 44 | + |
| 45 | +| Env var | Default | Meaning | |
| 46 | +|---|---|---| |
| 47 | +| `SUPERSET_OPENLINEAGE_ENABLED` | `true` | Master switch for the plugin | |
| 48 | +| `SUPERSET_OPENLINEAGE_NAMESPACE` | `superset` | OpenLineage job namespace | |
| 49 | +| `SUPERSET_OPENLINEAGE_PRODUCER` | Superset repo URL | `producer` URI on events | |
| 50 | +| `SUPERSET_OPENLINEAGE_JOB_NAME` | `$source.$identity` | Job-name template (`string.Template`) | |
| 51 | + |
| 52 | +### Job-name template |
| 53 | + |
| 54 | +A Python `string.Template`. Placeholders: `$source`, `$identity`, |
| 55 | +`$sql_editor_id`, `$client_id`, `$slice_id`, `$dashboard_id`, `$sql_hash`, |
| 56 | +`$schema`, `$catalog`, `$database`, `$username`. Placeholders that do not apply |
| 57 | +in a given context render empty and surrounding separators collapse; an empty |
| 58 | +result falls back to `$source.$sql_hash`. |
| 59 | + |
| 60 | +## Known limitations |
| 61 | + |
| 62 | +- Failed queries and cache hits emit no events (the config-only hooks provide no |
| 63 | + failure or cache signal). |
| 64 | +- Column-level lineage is emitted only for `CTAS`/`CVAS` statements (which have a |
| 65 | + real output table); plain `SELECT` queries (charts/dashboards and most SQL Lab) |
| 66 | + carry table-level inputs only. |
| 67 | +- Queries executed via Superset's newer SQL execution engine |
| 68 | + (`superset/sql/execution/*`) are not covered yet — they invoke `QUERY_LOGGER` |
| 69 | + but emit no completion event, so they produce no lineage (their pending stash |
| 70 | + entries are reclaimed by the teardown hook). |
| 71 | + |
| 72 | +## Tests |
| 73 | + |
| 74 | +Unit tests live under `superset_openlineage/tests/` and require |
| 75 | +`openlineage-python`, `sqlglot`, `SQLAlchemy` and `pytest`. They are not |
| 76 | +installed into the image. |
0 commit comments