DataHub
DataHub is a metadata platform for data discovery, governance and lineage. The DataHub technology plugin is a Hop lineage sink: it takes the in-engine lineage events of every pipeline and workflow run and writes them to DataHub, so DataHub shows which Hop pipelines read and write which files and tables, how a workflow runs its pipelines, and how every run went.
The sink writes to DataHub’s metadata API (GMS) directly. It needs nothing configured on the DataHub side and does not use DataHub’s OpenLineage endpoint. It is tested with DataHub 1.0, 1.7 and 1.8; DataHub Cloud serves the same API.
The plugin builds on the OpenLineage plugin, which has to be installed as well: it shares that plugin’s lineage mapping, asynchronous delivery and spool.
Quick start
-
Install the DataHub and OpenLineage plugins with the Marketplace. The DataHub plugin needs the OpenLineage one.
-
Create a Data Catalog of type DataHub with the URL of DataHub’s metadata service (GMS), for example
http://localhost:8080, orhttps://<your-company>.acryl.io/gmson DataHub Cloud, and a personal access token. Test checks both. -
Create a Lineage Sink of type DataHub that uses that data catalog.
-
Select the sink in the Lineage sink option of your pipeline and workflow run configurations.
-
Run a workflow. In DataHub, its pipelines are listed under the Apache Hop platform, with their tasks, their runs and the datasets they read and write.
To put a whole project in DataHub without running it, see Publishing a project without running it.
What you see in DataHub
| Hop | DataHub |
|---|---|
Pipeline, workflow |
A pipeline (DataFlow) on the Apache Hop platform, of type The sink writes the Apache Hop platform itself, with its name and logo, when DataHub doesn’t have
it yet, and checks again every ten minutes. A DataHub that has the platform keeps its own, also one
an older Hop version wrote. To get the current name and logo, delete the platform in DataHub
( |
Transform, action |
A task (DataJob) of that pipeline, of type A transform or action that is removed from its pipeline or workflow, or renamed, is soft-deleted in DataHub after the next successful run; it comes back if it is added again. A run that reaches DataHub late, from the spool after a newer run of the same file, is recorded as a run but changes neither the tasks nor what they read and write. |
A run of any of these |
A run (DataProcessInstance) named |
A pipeline or workflow run by a workflow action, or a pipeline run by a transform of another pipeline (Pipeline Executor, mapping) |
Its first transforms or actions list that action or transform as an upstream task, so lineage runs from the workflow into what it started; its run is a child of the run of that action or transform. |
File, table |
A dataset, named the way DataHub’s own sources name it: a table on its database platform
( |
Kafka topic (Kafka Consumer, Kafka Producer) |
A dataset on the |
Column mappings (SQL |
Column-level lineage, on the task and on the dataset. |
SQL a transform ran (Table Input, Execute SQL), expressions it calculated fields with (Formula, Calculator) |
The SQL is the task’s transformation logic, when the run ran exactly one statement; a run that
ran none, or several, leaves it empty. DataHub only takes SQL there, so a Formula’s or Calculator’s expressions are properties of the task instead:
|
A file or table a run wrote |
An operation on the dataset when the run succeeds: |
A file copied or moved (Copy files, Move files) |
The copy is linked to its own source as a |
Lineage between datasets runs through the tasks: orders.csv → Read orders → Write copy →
orders-copy.csv. A pipeline that reads two files and writes two files shows the two real paths,
not every input paired with every output.
Enabling the sink
The simplest way is a Lineage Sink of type DataHub, selected in a pipeline or workflow run configuration. It writes to the DataHub of a DataHub Data Catalog, with its URL, token and environment, so Hop reads from the same DataHub it writes to. The runs of that configuration report their lineage to it, and no variables are needed.
The sink can also be configured with variables, for every run of a Hop process. The lineage hub is off by default. Enable it and select the DataHub sink with these variables, as environment variables or in the Hop configuration (Tools > Edit config variables):
HOP_LINEAGE_ENABLED=Y
HOP_LINEAGE_SINK_IDS=datahub
HOP_LINEAGE_DATAHUB_URL=http://localhost:8080
# with authentication enabled in DataHub (always the case on DataHub Cloud):
HOP_LINEAGE_DATAHUB_TOKEN=<personal access token>
On DataHub Cloud the URL is the GMS endpoint, https://<your-company>.acryl.io/gms. The token
needs the privilege to edit lineage and entities, and to read entities: the sink checks what
DataHub already holds before it writes a schema (see Dataset schemas), a deprecation, a retired
task or a task’s upstream tasks. When DataHub cannot be reached for a read, the sink writes the
lineage now and keeps the event to make those decisions later. A token that may not read gets the
lineage without them, and the log says so once.
To send lineage to an OpenLineage collector as well, list both sinks:
HOP_LINEAGE_SINK_IDS=datahub,openlineage. Do not leave HOP_LINEAGE_SINK_IDS empty: that loads every
installed sink, and the OpenLineage sink, installed with this plugin, then fails to start without
its URL, which stops lineage delivery for every sink.
Configuration
| Variable | Default | Description |
|---|---|---|
|
(required) |
DataHub GMS URL. |
|
(empty) |
DataHub personal access token, sent as a bearer token. It can be stored encrypted, as |
|
|
DataHub environment of the datasets, pipelines and tasks. Use the value the other sources that describe the same datasets use, or their lineage does not join up. |
|
(empty) |
Keeps the pipelines of several Hop installations, or of projects with the same folder layout, apart in one DataHub: their ids are prefixed with it ( |
|
(empty) |
The platform instances of database servers, as |
|
|
When a dataset’s schema is written; see Dataset schemas. |
|
|
|
|
|
The DataHub user named as the creator of runs and deprecations. |
|
(empty) |
Folder that keeps events until DataHub accepted them; see Durability. |
|
|
Size limit of the spool (64 MiB). |
|
|
Parse the SQL of Table Input, Database Join, Execute SQL, Execute row SQL script and the SQL action to find the tables and columns it reads and writes. |
|
as OpenLineage |
Delivery settings, with the meaning and defaults of their OpenLineage counterparts. |
|
(empty), |
Trust store for a GMS with a certificate the JVM does not trust. |
Database platform instances
A DataHub ingestion source can have a platform_instance, to keep apart two database servers that
hold databases and tables of the same name. Its tables are then named with it:
warehouse.sales.public.orders instead of sales.public.orders. For Hop’s lineage to land on those
datasets, give the server the same instance in Hop: list its connection and the instance under
Database platform instances in the DataHub Data Catalog.
A table on that server is then named <instance>.<database>.<schema>.<table> and shows under its
instance, by the sink of a Lineage Sink that uses the catalog, by
publishing, and when Hop reads the catalog
(Check data catalog, Mask fields, the AI Assistant). Without instances, nothing changes. The
instance belongs to the server (host and port): every connection to it, and every database on it,
gets the same one. A sink configured with variables takes them from
HOP_LINEAGE_DATAHUB_DATABASE_INSTANCES, with the namespace Hop gives the server
(postgres://db.example.com:5432, the host in lower case and the port).
Durability
Events are written to DataHub on a background thread, so a run never waits for DataHub. With
HOP_LINEAGE_DATAHUB_SPOOL_DIR set, every event is stored in that folder before it is sent and
removed once DataHub accepted it: a DataHub outage or restart delays lineage instead of losing it.
The same process retries, in order, after a pause that doubles from one second to a minute; whatever
is left when it ends is sent by the next process that starts the sink, before its own events.
Processes can share a spool folder: each keeps its events in a folder of its own and only takes
over those of a process that is gone (see
OpenLineage durability).
With a spool folder, a rejected token, a wrong URL or a proxy that refuses the request (HTTP 401, 403, 404, 407) keeps the events for later, so they arrive once the configuration is fixed. Without one they are kept in memory, up to the buffer size, until the process ends. An event DataHub refuses as invalid is logged and dropped; when only one of its aspects is invalid, the rest of the event is still written. Events are written in batches, but each one is kept or done on its own: when a request fails halfway through a batch, the events DataHub accepted are not sent again.
When a hop-run ends, the sink waits for DataHub to accept what is still queued, up to
HOP_LINEAGE_DATAHUB_SHUTDOWN_DRAIN_MS (30 seconds by default). The log then reports
DataHub sink metrics: sent=…, failed=…, rejected=…, dropped=….
Dataset schemas
Hop knows the fields of the files it reads and writes and of the tables it writes, with their types.
With the default HOP_LINEAGE_DATAHUB_DATASET_SCHEMA=missing, the sink writes that schema only
when DataHub has none for the dataset yet, or the one it has was written by Hop: a table that
DataHub’s own database ingestion describes keeps that description. always writes Hop’s schema
regardless, never leaves schemas alone.
A table a query reads gets no schema from Hop: the query reads only some of its columns, and the rows it returns, with their aliases and expressions, are not the table’s schema either. The table’s schema comes from a Hop transform that writes it, or from DataHub’s own database ingestion.
Deleted and moved datasets
With HOP_LINEAGE_DATAHUB_LIFECYCLE=Y, a file a run deletes (Process files, or Move files and
Unzip when they remove a file) is marked deprecated in DataHub, with a note naming the task that deleted it. A file a run moves
(Move files) deprecates the old dataset and names the new one as its replacement. When a later run
writes the dataset again, the sink lifts its own deprecation; one a person wrote is never touched.
This is off by default: in DataHub a deprecation can notify the owners of a dataset, and a staging file that every run writes and deletes would be deprecated after every run.
Verifying
Run a pipeline and open DataHub: the pipeline is listed under the Apache Hop platform, its tasks on its Tasks tab and its runs on the Runs tab of each task. The Lineage tab of a dataset the pipeline wrote shows the tasks and datasets upstream of it.
Tools > Lineage sinks in Hop GUI, and the status page of a Hop Server, show what the sink sent, what waits and the last error; see Sink health.
The sink logs one line when it starts:
DataHub lineage sink initialized: gms=http://localhost:8080, env=PROD, dataset schemas=missing, lifecycle=off, spool=off
Unit test results
A pipeline unit test that runs with lineage, for example from the Run pipeline unit tests action in a workflow whose run configuration selects a DataHub lineage sink, reports each golden data set as an assertion run in DataHub: passed or failed, with what the comparison found, or an error when the rows could not be compared, for example because the golden data set could not be read.
The test’s run itself, of a changed copy of the pipeline, is not reported to a lineage sink, whether a run configuration selects it or the HOP_LINEAGE_* variables set it up. Before Hop 2.21, a sink set up with those variables got it as a run of the pipeline.
The assertion is on the tables and files the tested transform writes, as its metadata declares them: a test usually replaces that transform, so it is about what the transform would write. DataHub shows it on the dataset’s Quality tab, and the Check data catalog action can check it before a workflow reads the dataset.
DataHub only takes assertions on datasets: a test of a transform that writes no table or file is not sent.
Publishing a project without running it
The Publish to DataHub action, or hop datahub-publish on the command line, publishes a project’s pipelines and workflows to DataHub without running them: their tasks, the tables and files they declare, and the layouts of those files as dataset schemas.
It writes through a Lineage Sink of type DataHub, so the pipelines, tasks and datasets are the ones the runs report to.
The Publish lineage action and hop lineage-publish, which publish to any lineage sink, publish the same to a DataHub sink, without the documentation.
hop datahub-publish -j my-project -e prod -s prod-datahub
hop datahub-publish -j my-project -s prod-datahub -f '${PROJECT_HOME}/flows'
hop datahub-publish -j my-project -s prod-datahub -d -ip
| Option | Description |
|---|---|
|
The lineage sink of type DataHub to publish to. Required. |
|
The folder with the pipelines and workflows, with its subfolders. The default is the project’s home folder. |
|
Also publish the documentation of each pipeline and workflow as a DataHub document. Needs DataHub 1.7 or later. See Documentation. |
|
With |
|
With |
|
The project and environment, as for |
The command exits with 1 when a file can’t be read or DataHub didn’t accept everything.
Documentation
With -d, or Include documentation in the action, each pipeline and workflow also becomes a DataHub document.
The document holds what hop doc writes for the file: its description and extended description, its file name relative to the published folder, and when it was last changed.
Its parameters, with their default values, and the text of its notes are only added when asked for (-ip, -in, or Include parameters and Include notes in the action), as with hop doc: they end up in a catalog that more people read than the project.
The image of the graph is left out: DataHub shows the tasks itself.
-
The document is related to the pipeline or workflow and to each of its tasks, so it appears on their pages in DataHub.
-
The documents of a project sit under one document named
Hop project <name>. -
Publishing again updates the same documents.
Documents need DataHub 1.7 or later. Earlier versions, such as 1.0, have no documents and refuse them. The documents are sent after every pipeline and workflow is delivered, and the first one alone: when DataHub doesn’t take it, the others are not sent, and the publication fails with that reason. The pipelines, tasks and datasets are published all the same. Leave the option off for those versions. A document stays in DataHub when its pipeline or workflow is deleted.
Publishing past runs
The Publish runs to lineage action, or hop lineage-publish-runs on the command line, publishes the runs an Execution Information Location recorded to a DataHub lineage sink: each as the run instance it would have reported while it ran, with its start, end and result, its task runs, and the datasets its transforms declare.
A run keeps its id, so publishing it again updates the same run instance.
Reading from DataHub
The plugin also adds DataHub as a type of Data Catalog, so workflows can read what DataHub knows about a dataset. The Check data catalog action uses it to check, before a workflow goes on, that datasets exist in DataHub, aren’t deprecated, changed recently enough and passed their assertions. Mask fields uses it to mask the fields DataHub tags as personal data, and CSV file input and Text file input can fill their fields from the schema DataHub has for a file. The AI Assistant uses it to include the descriptions, owners, tags, glossary terms and deprecation of a pipeline’s datasets in its questions.
A Data Catalog has its own URL and token: it doesn’t use the HOP_LINEAGE_DATAHUB_* variables. Give
it the same environment as HOP_LINEAGE_DATAHUB_ENV, so a table resolves to the dataset the sink
writes for it. Its token only needs the privilege to view the datasets and their assertions.
Runs on Hop Server
A pipeline or workflow that runs on a Hop Server through a remote run configuration appears as one run, as a local run does: the server reports it as the client’s run, with its transforms, the datasets they read and write, the client’s file and the task that started it. It reports to the sinks of the client’s run configuration and to its own. See Runs on Hop Server on the OpenLineage page for how that works and which sinks the server can use.
Limitations
-
Column lineage through the stream (Table Input to Table Output) follows fields that keep their name; map them to other column names in the Table Output field list. A field renamed on the way, in Select values for example, has no column lineage.
-
A sink configured with the
HOP_LINEAGE_DATAHUB_*variables is the same for the whole Hop process: one DataHub and one environment per JVM, which a project environment (-e) can’t change. To send runs to different DataHubs or environments, select a Lineage Sink in their run configurations instead. -
A pipeline or workflow file that is moved, renamed or deleted stays in DataHub under its old path; the file in its new place is a new pipeline. Renaming the pipeline itself only changes its name.
-
A pipeline or workflow run on a Hop Server gets its transforms in DataHub only when the server has the DataHub plugin; without it the client reports the run without its transforms. The server also has to reach the sink’s DataHub URL; see Runs on Hop Server.
-
A pipeline run on Apache Beam or native Spark reports its transforms with the tables, files and other datasets they declare in their settings, not with what they only know while they run (a file name from a field, for example). Which transform failed shows only when the engine counted errors for it; otherwise every transform of a failed run fails. A Spark run in cluster mode has no row counts.