You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2026/08/13 07:31:31 UTC
(hop) branch main updated: openlineage: lineage sink emitting run, file and relational (column-l… (#7767)
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new aa3e21949d openlineage: lineage sink emitting run, file and relational (column-l… (#7767)
aa3e21949d is described below
commit aa3e21949dc58b3ffd3d22e33927356eee75617e
Author: Bart Maertens <ba...@know.bi>
AuthorDate: Thu Aug 13 09:31:25 2026 +0200
openlineage: lineage sink emitting run, file and relational (column-l… (#7767)
* openlineage: lineage sink emitting run, file and relational (column-level) lineage, shipped as a marketplace plugin. fixes #2946
* HopMetaDataPropertyType instead of emitters, other improvements and fixes #2946
* Update parent version to 2.20.0-SNAPSHOT
---------
Co-authored-by: Hans Van Akelyen <ha...@gmail.com>
---
assemblies/plugins/pom.xml | 6 +
assemblies/static/src/main/resources/LICENSE | 45 +-
.../hop/metadata/api/HopMetadataPropertyType.java | 10 +
.../integration-tests-openlineage.dev.yaml | 54 ++
.../integration-tests-openlineage.yaml | 104 +++
.../openlineage-warehouse-startup.sql | 67 ++
.../hop-dev-manual/modules/ROOT/pages/lineage.adoc | 48 +-
docs/hop-user-manual/modules/ROOT/nav.adoc | 2 +
.../technology/openlineage/dataset-identity.adoc | 208 ++++++
.../ROOT/pages/technology/openlineage/index.adoc | 154 +++++
.../modules/ROOT/pages/technology/technology.adoc | 1 +
.../apache/hop/lineage/LineageFileIdentity.java | 130 ++++
.../apache/hop/lineage/LineageMetadataWalker.java | 288 ++++++++
.../hop/lineage/LineageRelationalIdentity.java | 186 +++++
.../hop/lineage/LineageRelationalIoEmitter.java | 534 ++++++++++++++
.../hop/lineage/LineageTransformSchemaEmitter.java | 6 +-
.../org/apache/hop/lineage/LineageVariables.java | 31 +
.../apache/hop/lineage/api/RelationalLineage.java | 71 ++
.../hop/lineage/hub/LineageConfiguration.java | 34 +-
.../org/apache/hop/lineage/hub/LineageHub.java | 17 +-
.../apache/hop/lineage/model/LineageEventKind.java | 4 +-
.../lineage/model/RelationalIoLineagePayload.java | 254 +++++++
...geEventKind.java => RelationalIoOperation.java} | 21 +-
...eageEventKind.java => RelationalLifecycle.java} | 23 +-
.../apache/hop/lineage/model/RelationalTable.java | 83 +++
.../hop/lineage/model/RelationalWriteColumn.java | 81 +++
.../lineage/xp/LineageHubTransformFinishXp.java | 18 +-
.../hop/lineage/LineageFileIdentityTest.java | 100 +++
.../hop/lineage/LineageMetadataWalkerTest.java | 299 ++++++++
.../hop/lineage/LineageRelationalIdentityTest.java | 179 +++++
.../lineage/LineageRelationalIoEmitterTest.java | 332 +++++++++
.../openlineage/0001-openlineage-generate.hpl | 109 +++
.../openlineage/0002-openlineage-validate.hpl | 187 +++++
.../openlineage/0003-openlineage-warehouse.hpl | 121 ++++
.../0004-openlineage-warehouse-validate.hpl | 209 ++++++
.../0005-openlineage-warehouse-execsql.hpl | 79 +++
.../openlineage/0007-openlineage-insertupdate.hpl | 116 ++++
.../0008-openlineage-combinationlookup.hpl | 119 ++++
.../0009-openlineage-dimensionlookup.hpl | 130 ++++
.../openlineage/0010-openlineage-pgbulkloader.hpl | 110 +++
...-openlineage-dataset-columnlineage-validate.hpl | 214 ++++++
integration-tests/openlineage/dev-env-config.json | 19 +
integration-tests/openlineage/hop-config.json | 290 ++++++++
.../openlineage/main-0001-openlineage.hwf | 147 ++++
.../main-0002-openlineage-warehouse.hwf | 262 +++++++
.../openlineage/main-0003-openlineage-writers.hwf | 377 ++++++++++
.../metadata/pipeline-run-configuration/local.json | 17 +
.../openlineage/metadata/rdbms/warehouse.json | 26 +
.../metadata/workflow-run-configuration/local.json | 9 +
integration-tests/openlineage/project-config.json | 15 +
.../cratedbbulkloader/CrateDBBulkLoader.java | 1 +
.../cratedbbulkloader/CrateDBBulkLoaderField.java | 3 +-
.../cratedbbulkloader/CrateDBBulkLoaderMeta.java | 6 +-
.../CrateDBBulkLoaderLineageTest.java | 70 ++
.../monetdbbulkloader/MonetDbBulkLoaderMeta.java | 28 +-
.../MonetDbBulkLoaderLineageTest.java | 69 ++
.../mysqlbulkloader/MySqlBulkLoaderMeta.java | 22 +-
.../MySqlBulkLoaderLineageTest.java | 64 ++
.../orabulkloader/OraBulkLoaderMappingMeta.java | 7 +-
.../orabulkloader/OraBulkLoaderMeta.java | 8 +-
.../orabulkloader/OraBulkLoaderLineageTest.java | 73 ++
.../pgbulkloader/PGBulkLoaderMappingMeta.java | 3 +-
.../transforms/pgbulkloader/PGBulkLoaderMeta.java | 8 +-
.../pgbulkloader/PGBulkLoaderLineageTest.java | 72 ++
.../bulkloader/SnowflakeBulkLoaderField.java | 5 +-
.../bulkloader/SnowflakeBulkLoaderMeta.java | 3 +
.../bulkloader/SnowflakeBulkLoaderLineageTest.java | 61 ++
.../vertica/bulkloader/VerticaBulkLoaderField.java | 3 +-
.../vertica/bulkloader/VerticaBulkLoaderMeta.java | 3 +
.../bulkloader/VerticaBulkLoaderLineageTest.java | 61 ++
.../apache/hop/marketplace/optional-plugins.yaml | 6 +
.../bulkloader/RedshiftBulkLoaderField.java | 3 +-
.../bulkloader/RedshiftBulkLoaderMeta.java | 3 +
.../bulkloader/RedshiftBulkLoaderLineageTest.java | 70 ++
plugins/tech/openlineage/README.md | 222 ++++++
plugins/tech/openlineage/pom.xml | 131 ++++
plugins/tech/openlineage/src/assembly/assembly.xml | 38 +
.../openlineage/OpenLineageAsyncDispatcher.java | 214 ++++++
.../lineage/openlineage/OpenLineageEmitter.java | 23 +-
.../openlineage/OpenLineageEventMapper.java | 764 ++++++++++++++++++++
.../lineage/openlineage/OpenLineageHttpClient.java | 185 +++++
.../openlineage/OpenLineageLineageSink.java | 143 ++++
.../lineage/openlineage/OpenLineageSinkConfig.java | 367 ++++++++++
.../RelationalColumnLineageCorrelator.java | 153 +++++
.../lineage/openlineage/RelationalSqlParser.java | 167 +++++
.../openlineage/src/main/resources/version.xml | 18 +
.../OpenLineageAsyncDispatcherTest.java | 213 ++++++
.../openlineage/OpenLineageEventMapperTest.java | 765 +++++++++++++++++++++
.../openlineage/OpenLineageHttpClientTest.java | 153 +++++
.../lineage/openlineage/OpenLineageSinkTest.java | 216 ++++++
.../RelationalColumnLineageCorrelatorTest.java | 159 +++++
.../openlineage/RelationalSqlParserTest.java | 116 ++++
plugins/tech/pom.xml | 1 +
.../combinationlookup/CombinationLookup.java | 4 -
.../combinationlookup/CombinationLookupMeta.java | 3 +
.../transforms/combinationlookup/KeyField.java | 5 +-
.../CombinationLookupLineageTest.java | 70 ++
.../transforms/databaselookup/ReturnValue.java | 4 +-
.../hop/pipeline/transforms/delete/Delete.java | 1 +
.../pipeline/transforms/delete/DeleteKeyField.java | 3 +-
.../hop/pipeline/transforms/delete/DeleteMeta.java | 3 +
.../transforms/delete/DeleteLineageTest.java | 70 ++
.../dimensionlookup/DimensionLookupMeta.java | 12 +-
.../DimensionLookupLineageTest.java | 95 +++
.../insertupdate/InsertUpdateKeyField.java | 3 +-
.../transforms/insertupdate/InsertUpdateMeta.java | 3 +
.../transforms/insertupdate/InsertUpdateValue.java | 7 +-
.../insertupdate/InsertUpdateLineageTest.java | 81 +++
.../hop/pipeline/transforms/sql/ExecSql.java | 5 +
.../pipeline/transforms/tableinput/TableInput.java | 6 +
.../transforms/tableoutput/TableOutput.java | 59 ++
.../transforms/tableoutput/TableOutputData.java | 12 +
.../transforms/tableoutput/TableOutputField.java | 3 +-
.../transforms/tableoutput/TableOutputMeta.java | 8 +-
.../tableoutput/TableOutputLineageTest.java | 143 ++++
.../pipeline/transforms/update/UpdateField.java | 7 +-
.../pipeline/transforms/update/UpdateKeyField.java | 7 +-
.../transforms/update/UpdateLookupField.java | 7 +-
.../hop/pipeline/transforms/update/UpdateMeta.java | 3 +
.../transforms/update/UpdateLineageTest.java | 73 ++
120 files changed, 11250 insertions(+), 93 deletions(-)
diff --git a/assemblies/plugins/pom.xml b/assemblies/plugins/pom.xml
index dd88e02905..b90c2461e1 100644
--- a/assemblies/plugins/pom.xml
+++ b/assemblies/plugins/pom.xml
@@ -1701,6 +1701,12 @@
<version>${project.version}</version>
<type>zip</type>
</dependency>
+ <dependency>
+ <groupId>org.apache.hop</groupId>
+ <artifactId>hop-tech-openlineage</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
<dependency>
<groupId>org.apache.hop</groupId>
<artifactId>hop-tech-opensearch</artifactId>
diff --git a/assemblies/static/src/main/resources/LICENSE b/assemblies/static/src/main/resources/LICENSE
index 4a98ddaa0f..b425460c01 100644
--- a/assemblies/static/src/main/resources/LICENSE
+++ b/assemblies/static/src/main/resources/LICENSE
@@ -1339,6 +1339,9 @@ This product bundles hamcrest 2.1, which is available under a
This product bundles HdrHistogram 2.1.12, which is available under a
"Creative Commons" license. For details, see licenses/LICENSE-CC0.
+This product bundles HdrHistogram 2.2.2, which is available under a
+"Creative Commons" license. For details, see licenses/LICENSE-CC0.
+
This product bundles high-scale-lib 1.0.6, which is available under a
"The MIT" license. For details, see licenses/LICENSE-MIT.
@@ -1462,6 +1465,12 @@ This product bundles jackson-dataformat-xml 2.21.5, which is available under a
This product bundles jackson-datatype-jdk8 2.21.5, which is available under a
"Apache 2.0" license. For details, see LICENSE.
+This product bundles jackson-dataformat-yaml 2.21.5, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
+This product bundles jackson-datatype-jdk8 2.22.0, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
This product bundles jackson-datatype-joda 2.15.4, which is available under a
"Apache 2.0" license. For details, see LICENSE.
@@ -1474,16 +1483,19 @@ This product bundles jackson-datatype-jsr310 2.19.2, which is available under a
This product bundles jackson-datatype-jsr310 2.21.0, which is available under a
"Apache 2.0" license. For details, see LICENSE.
-This product bundles jackson-datatype-jsr310 2.21.2, which is available under a
+This product bundles jackson-datatype-jsr310 2.21.5, which is available under a
"Apache 2.0" license. For details, see LICENSE.
-This product bundles jackson-jaxrs-base 2.21.5, which is available under a
+This product bundles jackson-jaxrs-base 2.22.0, which is available under a
"Apache 2.0" license. For details, see LICENSE.
This product bundles jackson-jaxrs-json-provider 2.21.5, which is available under a
"Apache 2.0" license. For details, see LICENSE.
-This product bundles jackson-module-jaxb-annotations 2.21.5, which is available under a
+This product bundles jackson-module-blackbird 2.21.5, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
+This product bundles jackson-module-jaxb-annotations 2.22.0, which is available under a
"Apache 2.0" license. For details, see LICENSE.
This product bundles jackson-module-scala_2.12 2.21.0, which is available under a
@@ -2008,11 +2020,8 @@ This product bundles langchain4j-ollama 0.29.1, which is available under a
This product bundles langchain4j-open-ai 0.29.1, which is available under a
"Apache 2.0" license. For details, see LICENSE.
-This product bundles lettuce-core 6.5.5.RELEASE, which is available under a
-"The MIT" license. For details, see licenses/LICENSE-MIT.
-
-This product bundles leveldbjni-all 1.8, which is available under a
-"3-clause BSD" license. For details, see licenses/LICENSE-BSD3.
+This product bundles LatencyUtils 2.0.3, which is available under a
+"Creative Commons" license. For details, see licenses/LICENSE-CC0.
This product bundles libphonenumber 8.13.40, which is available under a
"Apache 2.0" license. For details, see LICENSE.
@@ -2149,6 +2158,15 @@ This product bundles metrics-logback 3.1.5, which is available under a
This product bundles metrics-spi 2.20.162, which is available under a
"Apache 2.0" license. For details, see LICENSE.
+This product bundles micrometer-observation 1.16.2, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
+This product bundles micrometer-core 1.16.2, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
+This product bundles micrometer-commons 1.16.2, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
This product bundles minimal-json 0.9.5, which is available under a
"The MIT" license. For details, see licenses/LICENSE-MIT.
@@ -2434,7 +2452,13 @@ This product bundles opencensus-contrib-http-util 0.31.1, which is available und
This product bundles opencsv 5.12.0, which is available under a
"Apache 2.0" license. For details, see LICENSE.
-This product bundles opentelemetry-api 1.65.0, which is available under a
+This product bundles openlineage-sql-java 1.46.0, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
+This product bundles openlineage-java 1.46.0, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
+This product bundles opentelemetry-api 1.62.0, which is available under a
"Apache 2.0" license. For details, see LICENSE.
This product bundles opentelemetry-common 1.65.0, which is available under a
@@ -2881,6 +2905,9 @@ This product bundles slf4j-api 2.0.18, which is available under a
This product bundles slf4j-nop 2.0.18, which is available under a
"The MIT" license. For details, see licenses/LICENSE-MIT.
+This product bundles snakeyaml 2.5, which is available under a
+"Apache 2.0" license. For details, see LICENSE.
+
This product bundles snakeyaml 2.6, which is available under a
"Apache 2.0" license. For details, see LICENSE.
diff --git a/core/src/main/java/org/apache/hop/metadata/api/HopMetadataPropertyType.java b/core/src/main/java/org/apache/hop/metadata/api/HopMetadataPropertyType.java
index d03f8aeb45..feb5234b69 100644
--- a/core/src/main/java/org/apache/hop/metadata/api/HopMetadataPropertyType.java
+++ b/core/src/main/java/org/apache/hop/metadata/api/HopMetadataPropertyType.java
@@ -54,6 +54,16 @@ public enum HopMetadataPropertyType {
// FIELDS
FIELD_LIST,
+ /**
+ * The pipeline stream field that feeds a mapping's target — the source half of a field-to-target
+ * mapping, whose other half names what it is written to ({@link #RDBMS_COLUMN}, for example). The
+ * two together describe "stream field X is written to Y".
+ *
+ * <p>At most one property per mapping object may carry this. Such an object often holds other
+ * properties that are also stream fields — the second bound of a BETWEEN condition, say — and
+ * annotating those makes the pair ambiguous.
+ */
+ STREAM_FIELD,
// FILES
FILE_PATH,
diff --git a/docker/integration-tests/integration-tests-openlineage.dev.yaml b/docker/integration-tests/integration-tests-openlineage.dev.yaml
new file mode 100644
index 0000000000..1deb70676d
--- /dev/null
+++ b/docker/integration-tests/integration-tests-openlineage.dev.yaml
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Developer-only override for manual exploration. NOT used by CI.
+#
+# Pins the Marquez API/admin ports and adds the graphical Marquez web UI, so you can
+# browse the lineage graph from the host while a pipeline emits lineage.
+#
+# Usage (brings up only Marquez + its UI, no Hop test container):
+# cd docker/integration-tests
+# docker compose -f integration-tests-openlineage.yaml \
+# -f integration-tests-openlineage.dev.yaml up marquez marquez-web
+#
+# Then open:
+# - Marquez web UI : http://localhost:3000
+# - Marquez API : http://localhost:5050/api/v1/namespaces
+#
+# The API host ports are 5050/5051 (not 5000/5001) because macOS reserves port 5000 for
+# AirPlay Receiver. The web UI reaches the API over the internal compose network, so this
+# only affects direct curl access from the host.
+
+services:
+ marquez:
+ ports:
+ - "5050:5000"
+ - "5051:5001"
+
+ marquez-web:
+ image: marquezproject/marquez-web:latest
+ # marquez-web only publishes a linux/amd64 image (see the API service note).
+ platform: linux/amd64
+ environment:
+ - MARQUEZ_HOST=marquez
+ - MARQUEZ_PORT=5000
+ - WEB_PORT=3000
+ ports:
+ - "3000:3000"
+ depends_on:
+ marquez:
+ condition: service_healthy
diff --git a/docker/integration-tests/integration-tests-openlineage.yaml b/docker/integration-tests/integration-tests-openlineage.yaml
new file mode 100644
index 0000000000..b89228dd4f
--- /dev/null
+++ b/docker/integration-tests/integration-tests-openlineage.yaml
@@ -0,0 +1,104 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+services:
+ integration_test_openlineage:
+ extends:
+ file: integration-tests-base.yaml
+ service: integration_test
+ depends_on:
+ marquez:
+ condition: service_healthy
+ postgres:
+ condition: service_healthy
+ links:
+ - marquez
+ - postgres
+ environment:
+ # Enable the in-engine lineage hub and select the OpenLineage sink.
+ - HOP_LINEAGE_ENABLED=Y
+ - HOP_LINEAGE_SINK_IDS=openlineage
+ - HOP_LINEAGE_OPENLINEAGE_URL=http://marquez:5000/api/v1/lineage
+ - HOP_LINEAGE_OPENLINEAGE_NAMESPACE=hop
+ # Parse Table Input / Execute SQL statements to recover their source/target tables.
+ - HOP_LINEAGE_OPENLINEAGE_SQL_PARSE=Y
+ # The sink drops events by default so lineage can never slow a pipeline down. These tests
+ # assert on what reached Marquez, so they need delivery to be lossless: wait for buffer
+ # capacity instead, and allow a slow (emulated) Marquez plenty of time to catch up.
+ - HOP_LINEAGE_OPENLINEAGE_OVERFLOW_POLICY=BLOCK
+ - HOP_LINEAGE_OPENLINEAGE_ENQUEUE_TIMEOUT_MS=60000
+
+ # "Warehouse" Postgres that the test pipelines read from and write to. Its host:port
+ # ("postgres":5432) is what the warehouse dataset namespace is keyed on
+ # (postgres://postgres:5432), so it must match run-tests.sh's POSTGRES_HOST default.
+ postgres:
+ image: postgres:14
+ environment:
+ - POSTGRES_USER=hop_user
+ - POSTGRES_PASSWORD=hop_password
+ - POSTGRES_DB=hop_database
+ healthcheck:
+ test: [ "CMD-SHELL", "pg_isready -U hop_user -d hop_database" ]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
+ volumes:
+ # Seeds public.orders_source and creates public.orders_target on first init.
+ - ./openlineage-warehouse-startup.sql:/docker-entrypoint-initdb.d/01-warehouse.sql:ro
+
+ marquez-db:
+ image: postgres:14
+ environment:
+ - POSTGRES_USER=marquez
+ - POSTGRES_PASSWORD=marquez
+ - POSTGRES_DB=marquez
+ healthcheck:
+ test: [ "CMD-SHELL", "pg_isready -U marquez -d marquez" ]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
+
+ marquez:
+ image: marquezproject/marquez:latest
+ # Marquez only publishes a linux/amd64 image; pin it so the platform is explicit
+ # (runs under emulation on arm64 hosts such as Apple Silicon).
+ platform: linux/amd64
+ ports:
+ - "5000"
+ - "5001"
+ environment:
+ - MARQUEZ_PORT=5000
+ - MARQUEZ_ADMIN_PORT=5001
+ - POSTGRES_HOST=marquez-db
+ - POSTGRES_PORT=5432
+ - POSTGRES_DB=marquez
+ - POSTGRES_USER=marquez
+ - POSTGRES_PASSWORD=marquez
+ # Marquez enables an OpenSearch-backed search by default; disable it so no
+ # extra search backend is required for the lineage integration test.
+ - SEARCH_ENABLED=false
+ depends_on:
+ marquez-db:
+ condition: service_healthy
+ healthcheck:
+ test: [ "CMD-SHELL", "wget -q -O - http://localhost:5001/healthcheck || exit 1" ]
+ interval: 15s
+ timeout: 5s
+ retries: 10
+ start_period: 30s
diff --git a/docker/integration-tests/openlineage-warehouse-startup.sql b/docker/integration-tests/openlineage-warehouse-startup.sql
new file mode 100644
index 0000000000..5cf7fed1ad
--- /dev/null
+++ b/docker/integration-tests/openlineage-warehouse-startup.sql
@@ -0,0 +1,67 @@
+/**
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+**/
+
+-- Seed the "warehouse" Postgres used by the OpenLineage warehouse-lineage integration test.
+-- The source table is populated; the target table is created empty for Table Output to fill.
+-- Runs automatically on first cluster init (mounted into /docker-entrypoint-initdb.d).
+
+CREATE TABLE IF NOT EXISTS public.orders_source (
+ id INTEGER,
+ amount NUMERIC(10, 2)
+);
+
+INSERT INTO public.orders_source (id, amount) VALUES
+ (1, 10.00),
+ (2, 20.00),
+ (3, 30.00);
+
+CREATE TABLE IF NOT EXISTS public.orders_target (
+ id INTEGER,
+ amount NUMERIC(10, 2)
+);
+
+-- Targets for the per-writer column-lineage tests (Insert/Update, Combination Lookup,
+-- Dimension Lookup, PostgreSQL bulk loader). Each is filled by reading orders_source.
+CREATE TABLE IF NOT EXISTS public.orders_upsert (
+ id INTEGER,
+ amount NUMERIC(10, 2)
+);
+
+CREATE TABLE IF NOT EXISTS public.orders_bulk (
+ id INTEGER,
+ amount NUMERIC(10, 2)
+);
+
+-- Combination Lookup junk dimension: technical key + the business-key columns.
+CREATE TABLE IF NOT EXISTS public.orders_combi (
+ combi_tk INTEGER,
+ id INTEGER,
+ amount NUMERIC(10, 2)
+);
+
+-- Dimension Lookup slowly-changing dimension: technical key, version, validity dates,
+-- the natural key and the dimension attribute.
+CREATE TABLE IF NOT EXISTS public.orders_dim (
+ dim_tk INTEGER,
+ version INTEGER,
+ date_from TIMESTAMP,
+ date_to TIMESTAMP,
+ id INTEGER,
+ amount NUMERIC(10, 2)
+);
diff --git a/docs/hop-dev-manual/modules/ROOT/pages/lineage.adoc b/docs/hop-dev-manual/modules/ROOT/pages/lineage.adoc
index 4e7f24737f..ae1c62e0d1 100644
--- a/docs/hop-dev-manual/modules/ROOT/pages/lineage.adoc
+++ b/docs/hop-dev-manual/modules/ROOT/pages/lineage.adoc
@@ -37,13 +37,13 @@ The public API lives under the Java package `org.apache.hop.lineage` in the `hop
|Package |Role
|`org.apache.hop.lineage`
-| `LineageVariables` — Hop variables (`@Variable`) that describe hub configuration.
+| `LineageVariables` — Hop variables (`@Variable`) that describe hub configuration. Also the per-kind emitters (`LineageFileIoEmitter`, `LineageRelationalIoEmitter`, `LineageHttpIoEmitter`, `LineageRunLifecycleEmitter`, `LineageTransformSchemaEmitter`), the shared dataset-identity helpers (`LineageFileIdentity`, `LineageRelationalIdentity`) and `LineageMetadataWalker` (see <<lineage-relational>>). Emitters are best-effort by construction: they no-op on missing arguments and never throw i [...]
|`org.apache.hop.lineage.context`
| `LineageContext`, `LineageSubjectType`, `LineagePortableFilename` — Immutable correlation (subject type, log channel, pipeline/workflow/transform/action names, `hopFilename` as on the engine/meta, optional `hopFilenamePortableKey` as `${PROJECT_HOME}/…` when derivable, optional attributes). Run identity for a single execution is the log channel id on the context.
|`org.apache.hop.lineage.model`
-| `LineageEvent`, `LineageEventKind`, `LineagePayload` and concrete payloads (structural, file I/O, HTTP, run lifecycle).
+| `LineageEvent`, `LineageEventKind`, `LineagePayload` and concrete payloads (structural, file I/O, relational I/O, HTTP, run lifecycle).
|`org.apache.hop.lineage.hub`
| `LineageHub`, `LineageConfiguration` — Queue, batching, flush, shutdown.
@@ -58,19 +58,61 @@ The public API lives under the Java package `org.apache.hop.lineage` in the `hop
| Extension points that call `LineageHub.flushQuietly()` on pipeline/workflow/server lifecycle (see <<lineage-flush>>).
|===
+[#lineage-relational]
+== Relational lineage is declared, not emitted
+
+A transform does not emit `RELATIONAL_IO` events itself. It **declares** the table access its
+metadata describes, and the engine derives the lineage from that declaration when the transform
+finishes.
+
+Two annotations carry the declaration:
+
+* **`@RelationalLineage`** (`org.apache.hop.lineage.api`) on the `ITransformMeta` class — opts the
+ transform in and states the `RelationalIoOperation` (`WRITE`, `DELETE`, …). Opting in is explicit
+ rather than inferred from the presence of a table property, because plenty of metadata names a
+ table without reading or writing its rows (checking that it exists, comparing two of them).
+* **`HopMetadataPropertyType`** values on the properties themselves — `RDBMS_CONNECTION`,
+ `RDBMS_SCHEMA`, `RDBMS_TABLE`, `RDBMS_TRUNCATE`, and `RDBMS_COLUMN` paired with the
+ database-neutral `STREAM_FIELD` on the same mapping object to express "stream field X is written
+ to column Y". These annotations already existed for search and metadata injection; lineage reuses
+ them.
+
+`LineageMetadataWalker` reads that declaration, recursing into nested metadata objects and lists.
+`LineageRelationalIoEmitter.emitDeclaredRelationalIo` then combines it with the facts only available
+at runtime — resolved variables, the connection the name refers to, the row shape, and the transform
+that produced each stream field — and emits the event. `LineageHubTransformFinishXp` drives this for
+every transform.
+
+Consequences worth knowing when adding a database transform:
+
+* Annotating the metadata is all that is required; there is no emission code to write, and no way to
+ silently forget it for a transform that already annotates its properties.
+* A column declaring `RDBMS_COLUMN` with no `STREAM_FIELD` is treated as generated by the
+ transform (a dimension's technical key, for example) and is left out of the column lineage rather
+ than reported with no origin.
+* Facts that only exist per row cannot be declared. A target table read from a row field, or a SQL
+ statement built at runtime, is still reported by the transform itself — Table Output's dynamic
+ table-name mode and the SQL-driven transforms (Table Input, Execute SQL) work that way.
+* A transform reports its table access when it finishes, which is after the pipeline run's own
+ completion event. Marquez creates dataset *versions* only from terminal run events, so such a
+ dataset shows `fields: []` and no current version in its API and UI, while its `columnLineage`
+ facet is stored and the lineage graph is complete. This is Marquez's ingestion rule, not a gap in
+ what Hop emits — worth knowing before investigating a dataset that looks empty.
+
== Event model
Each observation is a **`LineageEvent`**:
* **Event id** — Unique id (UUID by default).
* **Timestamp** — Milliseconds since epoch.
-* **`LineageEventKind`** — One of `RUN_LIFECYCLE`, `TRANSFORM_SCHEMA`, `FILE_IO`, `HTTP_IO`.
+* **`LineageEventKind`** — One of `RUN_LIFECYCLE`, `TRANSFORM_SCHEMA`, `FILE_IO`, `RELATIONAL_IO`, `HTTP_IO`.
* **`LineageContext`** — Who/what produced the observation (see above).
* **`LineagePayload`** — Optional typed payload; may be null if the kind and context are enough.
Payload types are plain Java types (strings, longs, enums) so sinks can serialize them without dragging engine objects across boundaries:
* **`FileIoLineagePayload`** — Operation (`READ`, `WRITE`, `COPY`, `MOVE`, `DELETE`), source/target URIs, byte counts, success, message, and optional **`FileIoContentSchema`**: tabular columns actually read/written (including JSONPath / YAML path / XPath locators) plus optional **`structureRoots`** (`FileIoSchemaNode` tree) merged from those paths for nested file layouts. Text File Output and JSON Output attach the **file** column layout (not the full transform output row when a subset i [...]
+* **`RelationalIoLineagePayload`** — Relational/JDBC table access: operation (`READ`, `WRITE`, `DELETE`, `EXEC`), the resolved **dataset namespace**, the input/output **`RelationalTable`** list (catalog/schema/table), the raw SQL when the engine cannot resolve the tables itself, an optional column schema, the connection's default catalog and schema, optional per-column provenance (**`RelationalWriteColumn`**: target column, stream field, origin transform), and an optional **`RelationalLi [...]
* **`HttpLineagePayload`** — `CLIENT` vs `SERVER`, method, URL, status, request/response bytes, duration, success, message.
* **`RunLifecycleLineagePayload`** — `STARTED` / `FINISHED` plus optional detail text.
* **`TransformSchemaLineagePayload`** — `INPUT` or `OUTPUT` plus a list of field names, Hop type names, length, and precision (boundary schema; emitted when a transform finishes). Fields usually come from runtime row metadata on the transform or row sets. If input was never observed (e.g. _Abort_ when `getRow()` immediately returns null), input is derived via `PipelineMeta#getPrevTransformFields`. If output was never written (e.g. _Detect empty stream_ with a non-empty stream), output is [...]
diff --git a/docs/hop-user-manual/modules/ROOT/nav.adoc b/docs/hop-user-manual/modules/ROOT/nav.adoc
index b02455a43e..f8a1265bae 100644
--- a/docs/hop-user-manual/modules/ROOT/nav.adoc
+++ b/docs/hop-user-manual/modules/ROOT/nav.adoc
@@ -519,6 +519,8 @@ under the License.
*** xref:technology/neo4j/neo4j-logging-schema.adoc[Neo4j Logging Schema]
** xref:technology/redis/index.adoc[Redis]
** xref:technology/google/index.adoc[Google]
+** xref:technology/openlineage/index.adoc[OpenLineage]
+*** xref:technology/openlineage/dataset-identity.adoc[Dataset identity]
* xref:hop-server/index.adoc[Hop Server]
** xref:hop-server/deploying.adoc[Deploying Hop Server]
*** xref:hop-server/deploy-project-image.adoc[Project in a Docker image]
diff --git a/docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/dataset-identity.adoc b/docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/dataset-identity.adoc
new file mode 100644
index 0000000000..266ac55ccb
--- /dev/null
+++ b/docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/dataset-identity.adoc
@@ -0,0 +1,208 @@
+////
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+////
+:documentationPath: /technology/openlineage/
+:language: en_US
+:description: How the Hop OpenLineage sink identifies datasets, and the naming another lineage producer has to match to stitch into Hop's graph.
+
+= OpenLineage dataset identity
+
+A dataset in OpenLineage is identified by the pair `(namespace, name)`.
+Two events carrying the *same* pair refer to the *same* node in the lineage graph.
+
+The most common silent failure in cross-tool lineage is one physical table showing up as two
+differently-named nodes: Hop writes `orders`, dbt reads `analytics.staging.orders`, and the graph
+never joins them. This page documents exactly what Hop emits, so a second producer can match it.
+
+Treat these rules as an API. Changing them re-keys existing lineage graphs, which is a breaking
+change — see <<Versioning>>.
+
+== Two namespaces, never conflate them
+
+There are two distinct namespace concepts, and they are not interchangeable:
+
+[cols="1,2,2",options="header"]
+|===
+|Concept |What it identifies |Source in Hop
+
+|*Job namespace*
+|The producer of the run — the Hop installation or environment
+|`HOP_LINEAGE_OPENLINEAGE_NAMESPACE`, default `hop`
+
+|*Dataset namespace*
+|The physical data source a dataset lives in — a database, a filesystem
+|Derived from the dataset's location, see below
+|===
+
+[WARNING]
+====
+The job namespace (`hop`) is *not* a valid dataset namespace for a database table.
+A dbt run emitting the same table must use the dataset namespace below, not the Hop job namespace.
+Aligning only the job namespace will *not* stitch datasets together.
+====
+
+== File datasets
+
+File (`FILE_IO`) datasets have two naming modes, selected by
+`HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING` (default `N`).
+
+=== Legacy mode (default)
+
+* *namespace* = the Hop job namespace (`HOP_LINEAGE_OPENLINEAGE_NAMESPACE`, default `hop`)
+* *name* = the last path segment of the file URI, with the full URI preserved in the `dataSource`
+ dataset facet
+
+This predates the contract and uses the job namespace as the dataset namespace. It does *not*
+follow the OpenLineage naming specification and will not reconcile a file across engines or tools.
+It remains the default only so that existing lineage graphs are not silently re-keyed.
+
+=== Spec mode (`HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING=Y`)
+
+Follows the https://openlineage.io/docs/spec/naming[OpenLineage naming specification], derived by
+the shared engine helper `LineageFileIdentity` so that the sink and the Beam/Spark engines agree on
+one identity for the same physical file.
+
+[cols="1,1,2",options="header"]
+|===
+|VFS scheme |namespace |name
+
+|`file://` |`file` |absolute path (`/data/customers.csv`)
+|`s3://`, `s3a://`, `s3n://` |`s3://{bucket}` |object key, no leading slash
+|`gs://` |`gs://{bucket}` |object key
+|`hdfs://` |`hdfs://{host}:{port}` |path
+|`abfss://`, `wasbs://` |`{scheme}://{container}@{account}` |path
+|other (`ftp`, `sftp`, `http`, …) |`{scheme}://{host}[:{port}]` |path
+|===
+
+URI user info (credentials) is dropped from the namespace, so no secret reaches the lineage graph.
+The exception is Azure, whose authority carries the container rather than a credential.
+
+Switching a deployment from legacy to spec mode re-keys its file datasets. That is why it is a
+flag rather than a straight change.
+
+== Relational datasets — the join key for other tools
+
+This is the identity another producer has to match to land on the same node as a Hop write.
+
+=== Dataset namespace
+
+[source]
+----
+{scheme}://{host}[:{port}]
+----
+
+* `scheme` is derived from the *Hop database type*, not from the raw JDBC sub-protocol — the two
+ differ (PostgreSQL is `postgresql` in JDBC but `postgres` in the OpenLineage naming spec).
+ Known types map as below; any other type falls back to its lowercased Hop type id.
+* `host` is taken from the connection, trimmed and *lowercased*.
+* `port` is the connection's port, or the database's default port when the connection leaves it
+ blank. It is omitted only when neither is known.
+
+[cols="1,1",options="header"]
+|===
+|Hop database type |Dataset namespace
+
+|PostgreSQL |`postgres://{host}:{port}`
+|MySQL, MariaDB |`mysql://{host}:{port}`
+|Redshift |`redshift://{host}:{port}`
+|Oracle |`oracle://{host}:{port}`
+|MS SQL Server (both drivers) |`mssql://{host}:{port}`
+|DB2 |`db2://{host}:{port}`
+|anything else |`{lowercased type id}://{host}:{port}`
+|===
+
+A connection with no host — an embedded or file-backed database — has no namespace to key on, and
+no relational lineage event is emitted for it.
+
+[NOTE]
+====
+*Known gap: Snowflake and BigQuery.* The OpenLineage naming specification names these by account
+(`snowflake://{account}`) and by a bare `bigquery` namespace respectively. Hop currently derives
+both from host and port like every other type, which means Snowflake does not match a dbt run's
+identity and BigQuery — having no host — emits nothing. Aligning them is tracked follow-up work.
+====
+
+=== Dataset name
+
+[source]
+----
+{database}.{schema}.{table}
+----
+
+* Only the segments the database actually has are included, joined with `.`; a database with no
+ catalog level yields `{schema}.{table}`.
+* Segments are emitted *verbatim*: trimmed, but never re-cased and never quoted. No surrounding
+ quotes, no trailing semicolon.
+* A table recovered by parsing SQL carries no catalog segment (SQL cannot name one) and may carry
+ no schema either. Blank segments are filled from the connection's own catalog
+ (`DatabaseMeta.getDatabaseName()`) and preferred schema, so a read of `schema.table` and a write
+ of `catalog.schema.table` resolve to one identity.
+
+[NOTE]
+====
+*Known gap: identifier casing.* The naming specification asks for the name as the database itself
+stores it in its catalog — upper case for Snowflake, lower case for PostgreSQL — unless the
+identifier was quoted. Hop emits what the transform was configured with, so a Table Output
+configured `PUBLIC.ORDERS` and a `select … from public.orders` currently produce two nodes.
+Until per-dialect normalisation lands, configure table and schema names in the case the database
+stores them.
+====
+
+=== Worked example
+
+A Hop pipeline writes `analytics.staging.orders` in PostgreSQL on `db:5432`; a dbt model then
+reads it to build `analytics.marts.daily_orders`. Both must emit the handoff table as:
+
+[source]
+----
+namespace: postgres://db:5432
+name: analytics.staging.orders
+----
+
+The graph query "what fed `analytics.marts.daily_orders`?" then traverses Hop → dbt through one
+shared node, with nothing having to infer that two differently-named nodes are the same table.
+If such a guess is required, the identities are not aligned.
+
+== Run identity
+
+Dataset identity answers "is this the same table". Run identity answers "is this run a child of
+the Hop run". The run id this sink emits is:
+
+* *runId* = the Hop log channel id of the executing pipeline or workflow
+ (`LineageContext.getLogChannelId()`). File and relational I/O are correlated to the *parent
+ pipeline* run via the `pipelineLogChannelId` context attribute.
+
+OpenLineage types `runId` as a UUID. Hop log channel ids are already UUID strings, so the emitted
+value is that id verbatim. Only the synthetic fallback used when no log channel id is available —
+never part of a real cross-tool stitch — is derived deterministically from the job name.
+
+A downstream producer that wants to attach as a child of the Hop run propagates this value as the
+OpenLineage `ParentRunFacet` `run.runId`, with `job.namespace` set to the Hop job namespace and
+`job.name` to the Hop workflow or pipeline name.
+
+== Versioning
+
+This is *contract v3*.
+
+* *v3* documents the relational identity as implemented by the engine's `RELATIONAL_IO` emitter:
+ the namespace scheme is derived from the Hop database type rather than the JDBC sub-protocol,
+ and the two known gaps above (Snowflake/BigQuery namespaces, identifier casing) are stated
+ rather than assumed.
+* *v2* added the OpenLineage-spec file naming mode, opt-in via
+ `HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING`, keeping legacy file naming as the default.
+
+Any change to the rules on this page is breaking: it must bump the version here and be reflected
+in every producer that stitches into Hop's graph.
diff --git a/docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/index.adoc b/docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/index.adoc
new file mode 100644
index 0000000000..35d99ff7d1
--- /dev/null
+++ b/docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/index.adoc
@@ -0,0 +1,154 @@
+////
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+////
+:documentationPath: /technology/openlineage/
+:language: en_US
+:description: The OpenLineage technology plugin is a Hop lineage sink that maps the engine's lineage events to OpenLineage JSON and posts them to a collector such as Marquez.
+
+= OpenLineage
+
+https://openlineage.io/[OpenLineage] is an open standard for lineage metadata collection.
+The OpenLineage technology plugin is a Hop **lineage sink**: it subscribes to the in-engine
+xref:dev-manual::lineage.adoc[lineage observation hub] and maps Hop's neutral lineage events
+to spec-correct OpenLineage `RunEvent` JSON, which it posts to any OpenLineage-compatible collector.
+The primary target is https://marquezproject.github.io/marquez/[Marquez].
+
+Events are generated by the spec's official `openlineage-java` client, delivered asynchronously off
+the pipeline thread, retried on transient HTTP failures, and (by default) buffered losslessly under
+back-pressure.
+
+== Enabling the sink
+
+The lineage hub is disabled by default. Enable it and select the OpenLineage sink with these
+**engine-scoped** variables (see xref:dev-manual::lineage.adoc[the lineage hub] for the hub-wide
+variables):
+
+[cols="2,1,3",options="header"]
+|===
+|Variable |Default |Description
+
+|`HOP_LINEAGE_ENABLED` |`N` |Set to `Y` to enable the lineage hub.
+|`HOP_LINEAGE_SINK_IDS` |_(empty)_ |Set to `openlineage` to load this sink.
+|===
+
+The sink itself reads the following variables when it initializes:
+
+[cols="2,1,3",options="header"]
+|===
+|Variable |Default |Description
+
+|`HOP_LINEAGE_OPENLINEAGE_URL` |_(required)_ |Collector URL, e.g. `\http://marquez-api:5000/api/v1/lineage`. Must be an absolute `http(s)` URL.
+|`HOP_LINEAGE_OPENLINEAGE_NAMESPACE` |`hop` |OpenLineage *job* namespace (the producing Hop environment).
+|`HOP_LINEAGE_OPENLINEAGE_PRODUCER` |_(plugin URL)_ |OpenLineage `producer` field.
+|`HOP_LINEAGE_OPENLINEAGE_SQL_PARSE` |`Y` |Parse `SELECT`/`INSERT` statements (Table Input, Execute SQL) to recover their source/target tables and column lineage. Set to `N` to disable SQL parsing.
+|`HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING` |`N` |`Y` names file datasets by the OpenLineage naming spec (scheme → namespace, path → name, e.g. `s3://bucket` + `key`) so a file reconciles across engines/tools; `N` keeps the legacy job-namespace + filename identity. Switching re-keys existing file datasets.
+|`HOP_LINEAGE_OPENLINEAGE_API_KEY` |_(empty)_ |Optional bearer token sent as `Authorization: Bearer …`.
+|`HOP_LINEAGE_OPENLINEAGE_CONNECT_TIMEOUT_MS` |`5000` |HTTP connect timeout.
+|`HOP_LINEAGE_OPENLINEAGE_READ_TIMEOUT_MS` |`30000` |HTTP read/response timeout.
+|`HOP_LINEAGE_OPENLINEAGE_BUFFER_SIZE` |`10000` |Async outbound queue capacity.
+|`HOP_LINEAGE_OPENLINEAGE_MAX_RETRIES` |`3` |Retries per event on transient HTTP failure (exponential backoff).
+|`HOP_LINEAGE_OPENLINEAGE_RETRY_BACKOFF_MS` |`500` |Initial retry backoff; doubles each attempt.
+|`HOP_LINEAGE_OPENLINEAGE_OVERFLOW_POLICY` |`DROP` |What to do when the outbound buffer is full. `DROP` = drop the event and count it, so lineage never slows the pipeline down. `BLOCK` = wait for capacity, bounded by `HOP_LINEAGE_OPENLINEAGE_ENQUEUE_TIMEOUT_MS`, for deployments that would rather lose throughput than lose lineage.
+
+|`HOP_LINEAGE_OPENLINEAGE_ENQUEUE_TIMEOUT_MS` |`5000` |Under `BLOCK`, how long (ms) to wait for buffer capacity before dropping the event.
+|`HOP_LINEAGE_OPENLINEAGE_SHUTDOWN_DRAIN_MS` |`30000` |Maximum time to drain the queue on shutdown.
+|`HOP_LINEAGE_OPENLINEAGE_METRICS_INTERVAL_MS` |`0` |If > 0, periodically log `sent/failed/dropped/queued` counts (`0` = off).
+|`HOP_LINEAGE_OPENLINEAGE_TRUSTSTORE_PATH` |_(empty)_ |Trust/key store for HTTPS collectors with a custom CA/cert.
+|`HOP_LINEAGE_OPENLINEAGE_TRUSTSTORE_PASSWORD` |_(empty)_ |Store password (used with the trust store path).
+|`HOP_LINEAGE_OPENLINEAGE_KEYSTORE_TYPE` |`PKCS12` |Trust store type (e.g. `PKCS12`, `JKS`).
+|===
+
+Events are buffered in memory and delivered by a single ordered worker thread; on a hard crash
+undelivered events are lost. There is no proxy setting — route via the JVM `-Dhttps.proxyHost`
+properties if needed.
+
+== Event mapping
+
+[cols="1,2",options="header"]
+|===
+|Hop lineage event |OpenLineage output
+
+|`RUN_LIFECYCLE` |`RunEvent` — `START` / `COMPLETE` / `FAIL`.
+|`FILE_IO` |`RunEvent` (`OTHER`) with physical file datasets (`dataSource` facet, plus a `schema` facet when Hop provides the file's column schema), correlated to the parent pipeline run.
+|`RELATIONAL_IO` |`RunEvent` (`OTHER`) with relational table datasets — see <<Database lineage>>. Carries a `schema` facet, a `columnLineage` facet when column mappings are derivable, and a `lifecycleStateChange` facet for truncate/overwrite writes.
+|`TRANSFORM_SCHEMA` |Skipped (internal row shapes between transforms, not physical datasets).
+|`HTTP_IO` |Skipped.
+|===
+
+The run id is the executing pipeline/workflow log-channel id; file I/O is correlated to the parent
+pipeline run so inputs/outputs appear on the pipeline job in Marquez. Transform and action run
+events carry a `ParentRunFacet` so their jobs attach to the parent pipeline/workflow run in the
+lineage graph rather than appearing as disconnected jobs.
+
+== Database lineage
+
+`RELATIONAL_IO` events record the relational tables a transform reads from or writes to. The physical
+dataset is identified by a database namespace (e.g. `postgres://host:5432`) and a fully-qualified
+`database.schema.table` name (see <<Dataset identity>>), so a Hop write and, for example, a dbt read
+of the same table land on **one** node in the lineage graph.
+
+The following transforms emit relational lineage:
+
+* **Reads** — *Table Input* (its `SELECT` is parsed to recover the source tables and column lineage).
+* **Writes** — *Table Output*, *Insert / Update*, *Update*, *Dimension Lookup/Update*,
+ *Combination Lookup/Update*, and the database bulk loaders (CrateDB, MonetDB, MySQL, Oracle,
+ PostgreSQL, Vertica).
+* **Deletes** — *Delete* reports the affected table only. A delete produces no columns, so the event
+ carries neither a column schema nor column lineage.
+* **Reads and writes** — *Execute SQL* (its statements are parsed for both input and output tables).
+
+=== SQL parsing
+
+For transforms that only provide a SQL statement (Table Input, Execute SQL), the sink recovers the
+tables — and, for an `INSERT … SELECT`, the column-level lineage — by parsing the statement with the
+OpenLineage SQL parser. Parsing is on by default and controlled by `HOP_LINEAGE_OPENLINEAGE_SQL_PARSE`.
+Tables named without a schema or catalog are qualified using the connection's default database and
+preferred schema, so a bare `SELECT … FROM orders` shares one identity with a schema-qualified write
+of the same table.
+
+=== Column-level lineage
+
+The sink emits an OpenLineage `columnLineage` facet on the output dataset in two cases:
+
+* **SQL-derived** — an `INSERT … SELECT` (Execute SQL) maps each target column to the source columns
+ the parser resolves it from.
+* **Stream path** — a relational write transform whose columns are traced back through the pipeline
+ stream to the read (or lookup) that produced each field, giving `target.column ← source.column`
+ edges. Covered writers: *Table Output*, *Insert / Update*, *Update*, *Dimension Lookup/Update*
+ (natural keys and argument-bound attributes), *Combination Lookup/Update* (keys), and the database
+ bulk loaders. Generated columns — a dimension's technical key, version and validity dates — have no
+ stream source and carry no column lineage.
+
+Writes that replace their target (a truncate, or the target of an overwrite) additionally carry a
+`lifecycleStateChange` facet.
+
+== Dataset identity
+
+The `(namespace, name)` rules the sink uses to identify datasets — and the naming another producer
+must match to stitch into Hop's lineage graph — are a stable, versioned contract documented in
+xref:technology/openlineage/dataset-identity.adoc[OpenLineage dataset identity]. Read it before
+integrating a second lineage producer against the same collector.
+
+== Verifying
+
+. Set `HOP_LINEAGE_ENABLED=Y`, `HOP_LINEAGE_SINK_IDS=openlineage`, and `HOP_LINEAGE_OPENLINEAGE_URL`.
+. Run a pipeline that reads a file (e.g. a CSV input).
+. Open the Marquez UI and confirm a job run (`START` / `COMPLETE`) and at least one file dataset.
+. For database lineage, run a pipeline that reads and writes a table (e.g. Table Input → Table
+ Output) and confirm the input/output table datasets — and, for an `INSERT … SELECT`, the
+ `columnLineage` facet — in Marquez.
+
+On startup the sink logs `OpenLineage lineage sink initialized: url=…, namespace=…`.
diff --git a/docs/hop-user-manual/modules/ROOT/pages/technology/technology.adoc b/docs/hop-user-manual/modules/ROOT/pages/technology/technology.adoc
index 80cb9dc4cf..79a9ca6a16 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/technology/technology.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/technology/technology.adoc
@@ -32,4 +32,5 @@ The technologies supported by Hop currently include:
* xref:technology/memgraph/index.adoc[Memgraph]
* xref:technology/neo4j/index.adoc[Neo4j]
** xref:technology/neo4j/working-with-neo4j-data.adoc[Working with Neo4j data]
+* xref:technology/openlineage/index.adoc[OpenLineage]
* xref:technology/redis/index.adoc[Redis]
diff --git a/engine/src/main/java/org/apache/hop/lineage/LineageFileIdentity.java b/engine/src/main/java/org/apache/hop/lineage/LineageFileIdentity.java
new file mode 100644
index 0000000000..6fa80d3f39
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/LineageFileIdentity.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Locale;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Derives the OpenLineage {@code (namespace, name)} identity of a file / object-store dataset from
+ * its VFS URI, per the OpenLineage dataset naming specification (<a
+ * href="https://openlineage.io/docs/spec/naming">openlineage.io/docs/spec/naming</a>). Kept in the
+ * engine (like {@link LineageRelationalIdentity}) so every producer — the OpenLineage sink, and the
+ * Beam/Spark engines — derives the <b>same</b> identity for the same physical file, letting a file
+ * written by one and read by another reconcile onto one node.
+ *
+ * <p>The rules by URI scheme:
+ *
+ * <ul>
+ * <li><b>Local file</b> ({@code file://}): namespace {@code file}, name the absolute path.
+ * <li><b>Object stores</b> ({@code s3://}, {@code gs://}): namespace {@code scheme://bucket},
+ * name the object key (no leading slash).
+ * <li><b>Azure ADLS</b> ({@code abfss://}, {@code wasbs://}): namespace {@code
+ * scheme://container@account…}, name the path (the container lives in the URI authority, not
+ * a credential).
+ * <li><b>Everything else</b> ({@code hdfs://}, {@code ftp://}, {@code sftp://}, {@code
+ * http(s)://} …): namespace {@code scheme://host[:port]}, name the path.
+ * </ul>
+ *
+ * <p>User info (e.g. {@code sftp://user:password@host}) is dropped from the namespace so
+ * credentials never leak into lineage — except for Azure, whose authority carries the container,
+ * not a secret.
+ */
+public final class LineageFileIdentity {
+
+ /** Schemes whose authority is a bucket and whose name is the object key with no leading slash. */
+ private static final Set<String> OBJECT_STORE_SCHEMES = Set.of("s3", "gs");
+
+ /** Schemes whose authority ({@code container@account}) is location, not a credential. */
+ private static final Set<String> AZURE_SCHEMES = Set.of("abfs", "abfss", "wasb", "wasbs");
+
+ private LineageFileIdentity() {}
+
+ /** The OpenLineage {@code (namespace, name)} of a file dataset. */
+ public record Identity(String namespace, String name) {}
+
+ /**
+ * Derives the identity of the file at {@code uri}, or {@code null} when the URI is blank, has no
+ * scheme, or cannot be parsed (the caller then falls back to its legacy naming).
+ */
+ public static Identity of(String uri) {
+ if (StringUtils.isBlank(uri)) {
+ return null;
+ }
+ URI parsed = parse(uri.trim());
+ if (parsed == null) {
+ return null;
+ }
+ String scheme = normalizeScheme(parsed.getScheme());
+ if (scheme == null) {
+ return null;
+ }
+ String path = parsed.getPath() == null ? "" : parsed.getPath();
+
+ if ("file".equals(scheme)) {
+ return new Identity("file", StringUtils.isBlank(path) ? "/" : path);
+ }
+ if (OBJECT_STORE_SCHEMES.contains(scheme)) {
+ String bucket = parsed.getHost();
+ String key = stripLeadingSlash(path);
+ return StringUtils.isBlank(bucket)
+ ? new Identity(scheme, key)
+ : new Identity(scheme + "://" + bucket, key);
+ }
+
+ String authority = AZURE_SCHEMES.contains(scheme) ? parsed.getAuthority() : hostPort(parsed);
+ String namespace = StringUtils.isBlank(authority) ? scheme : scheme + "://" + authority;
+ return new Identity(namespace, StringUtils.isBlank(path) ? "/" : path);
+ }
+
+ private static URI parse(String uri) {
+ try {
+ return new URI(uri);
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+
+ private static String normalizeScheme(String rawScheme) {
+ if (StringUtils.isBlank(rawScheme)) {
+ return null;
+ }
+ String scheme = rawScheme.trim().toLowerCase(Locale.ROOT);
+ return switch (scheme) {
+ case "s3", "s3a", "s3n" -> "s3";
+ case "gs", "gcs" -> "gs";
+ default -> scheme;
+ };
+ }
+
+ /** Host and port only, so any {@code user:password@} authority is never included. */
+ private static String hostPort(URI uri) {
+ String host = uri.getHost();
+ if (StringUtils.isBlank(host)) {
+ return null;
+ }
+ return uri.getPort() > 0 ? host + ":" + uri.getPort() : host;
+ }
+
+ private static String stripLeadingSlash(String path) {
+ return path != null && path.startsWith("/") ? path.substring(1) : path;
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/LineageMetadataWalker.java b/engine/src/main/java/org/apache/hop/lineage/LineageMetadataWalker.java
new file mode 100644
index 0000000000..ee3238345f
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/LineageMetadataWalker.java
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.HopMetadataPropertyType;
+
+/**
+ * Reads the relational lineage a transform declares on its metadata: which table it touches, on
+ * which connection, and how its stream fields map to that table's columns.
+ *
+ * <p>This replaces per-transform emission code. A transform marked {@link RelationalLineage}
+ * describes its table access once, declaratively, through the {@code RDBMS_*} property annotations
+ * it already carries for search and metadata injection; the engine derives the lineage from that.
+ * The alternative — every transform assembling and emitting its own event — was both repetitive and
+ * silently incomplete, since nothing fails when a transform simply forgets to do it.
+ *
+ * <p>What is found here is the <b>static</b> half of a lineage observation. Resolving variables,
+ * reading the row shape and tracing each stream field back to the transform that produced it are
+ * runtime concerns, handled by the caller (see {@code LineageRelationalIoEmitter}).
+ *
+ * <p>Walking is defensive throughout: unreadable fields are skipped, cycles are broken, and any
+ * failure yields a partial or empty result rather than an exception, because lineage must never
+ * affect the transform it is observing.
+ */
+public final class LineageMetadataWalker {
+
+ /** Guards against a pathological or cyclic metadata graph. */
+ private static final int MAX_DEPTH = 6;
+
+ private LineageMetadataWalker() {}
+
+ /** One stream-field-to-column mapping declared on a metadata object. */
+ public record ColumnMapping(String targetColumn, String streamField) {}
+
+ /**
+ * The relational access a transform's metadata declares. All string values are raw (unresolved)
+ * metadata; the caller substitutes variables.
+ */
+ public record Declaration(
+ RelationalIoOperation operation,
+ String connectionName,
+ String schemaName,
+ String tableName,
+ boolean overwrite,
+ boolean tableNameFromField,
+ List<ColumnMapping> columns) {
+
+ /** Whether this declaration can produce a dataset identity at all. */
+ public boolean isUsable() {
+ return !StringUtils.isBlank(connectionName)
+ && !StringUtils.isBlank(tableName)
+ && !tableNameFromField;
+ }
+ }
+
+ /**
+ * Reads the declaration from a transform metadata instance, or returns {@code null} when the
+ * class is not annotated with {@link RelationalLineage} (i.e. it does not participate in
+ * relational lineage).
+ */
+ public static Declaration read(Object transformMeta) {
+ if (transformMeta == null) {
+ return null;
+ }
+ RelationalLineage declared = transformMeta.getClass().getAnnotation(RelationalLineage.class);
+ if (declared == null) {
+ return null;
+ }
+ Collector collector = new Collector(declared);
+ try {
+ collector.walk(transformMeta, 0);
+ } catch (Exception e) {
+ // Partial results are still useful; a broken walk must not reach the transform.
+ return collector.toDeclaration();
+ }
+ return collector.toDeclaration();
+ }
+
+ /** Accumulates the annotated values found while descending through a metadata object graph. */
+ private static final class Collector {
+ private final RelationalLineage declared;
+ private final Set<Object> visited =
+ java.util.Collections.newSetFromMap(new IdentityHashMap<>());
+ private final List<ColumnMapping> columns = new ArrayList<>();
+
+ private String connectionName;
+ private String schemaName;
+ private String tableName;
+ private String tableNameFromFieldValue;
+ private boolean overwrite;
+
+ Collector(RelationalLineage declared) {
+ this.declared = declared;
+ }
+
+ void walk(Object node, int depth) {
+ if (node == null || depth > MAX_DEPTH || !visited.add(node)) {
+ return;
+ }
+ // A mapping object carrying both halves of a column pair is a leaf: record the pair and do
+ // not descend further, so nested strings cannot be mistaken for another mapping.
+ if (collectColumnPair(node)) {
+ return;
+ }
+ for (Class<?> c = node.getClass(); c != null && c != Object.class; c = c.getSuperclass()) {
+ for (Field field : c.getDeclaredFields()) {
+ HopMetadataProperty property = field.getAnnotation(HopMetadataProperty.class);
+ if (property == null) {
+ continue;
+ }
+ Object value = readField(field, node);
+ if (value == null) {
+ continue;
+ }
+ collectScalar(property.hopMetadataPropertyType(), field, value);
+ descend(value, depth);
+ }
+ }
+ }
+
+ /** Follows nested metadata objects and collections, skipping plain values. */
+ private void descend(Object value, int depth) {
+ if (value instanceof Collection<?> collection) {
+ for (Object element : collection) {
+ if (isMetadataObject(element)) {
+ walk(element, depth + 1);
+ }
+ }
+ } else if (value instanceof Map<?, ?> map) {
+ for (Object element : map.values()) {
+ if (isMetadataObject(element)) {
+ walk(element, depth + 1);
+ }
+ }
+ } else if (isMetadataObject(value)) {
+ walk(value, depth + 1);
+ }
+ }
+
+ /**
+ * Records a {@code target column ← stream field} pair when an object declares both halves.
+ * Requiring both is what keeps generated columns — a dimension's technical key declares a
+ * column but no source — out of the column lineage instead of appearing with no origin.
+ *
+ * <p>A mapping object is expected to declare exactly one of each. Declaring two is ambiguous —
+ * a key mapping holds other stream fields, such as the second bound of a BETWEEN condition, and
+ * nothing says which one feeds the column — so nothing is recorded rather than the last one
+ * found silently winning.
+ */
+ private boolean collectColumnPair(Object node) {
+ String target = null;
+ String source = null;
+ int targets = 0;
+ int sources = 0;
+ for (Class<?> c = node.getClass(); c != null && c != Object.class; c = c.getSuperclass()) {
+ for (Field field : c.getDeclaredFields()) {
+ HopMetadataProperty property = field.getAnnotation(HopMetadataProperty.class);
+ if (property == null || field.getType() != String.class) {
+ continue;
+ }
+ if (property.hopMetadataPropertyType() == HopMetadataPropertyType.RDBMS_COLUMN) {
+ target = (String) readField(field, node);
+ targets++;
+ } else if (property.hopMetadataPropertyType() == HopMetadataPropertyType.STREAM_FIELD) {
+ source = (String) readField(field, node);
+ sources++;
+ }
+ }
+ }
+ if (targets > 1 || sources > 1) {
+ return false;
+ }
+ if (StringUtils.isBlank(target) || StringUtils.isBlank(source)) {
+ return false;
+ }
+ columns.add(new ColumnMapping(target, source));
+ return true;
+ }
+
+ private void collectScalar(HopMetadataPropertyType type, Field field, Object value) {
+ switch (type) {
+ case RDBMS_CONNECTION -> connectionName = firstNonBlank(connectionName, value);
+ case RDBMS_SCHEMA -> schemaName = firstNonBlank(schemaName, value);
+ case RDBMS_TABLE -> {
+ if (field.getName().equals(declared.tableNameFromFieldProperty())) {
+ tableNameFromFieldValue = firstNonBlank(tableNameFromFieldValue, value);
+ } else {
+ tableName = firstNonBlank(tableName, value);
+ }
+ }
+ case RDBMS_TRUNCATE -> overwrite = overwrite || meansOverwrite(value);
+ default -> {
+ // Not part of the relational dataset identity.
+ }
+ }
+ }
+
+ /**
+ * Whether a {@code RDBMS_TRUNCATE} value marks the write as replacing the target. A boolean
+ * says so directly; loaders that express it as a load action ({@code TRUNCATE}, {@code
+ * REPLACE}) are matched against the values the transform declared.
+ */
+ private boolean meansOverwrite(Object value) {
+ if (value instanceof Boolean b) {
+ return b;
+ }
+ if (value instanceof String s) {
+ for (String candidate : declared.overwriteWhen()) {
+ if (candidate.equalsIgnoreCase(s.trim())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ Declaration toDeclaration() {
+ boolean fromField =
+ !StringUtils.isBlank(declared.tableNameFromFieldProperty())
+ && !StringUtils.isBlank(tableNameFromFieldValue);
+ return new Declaration(
+ declared.operation(),
+ connectionName,
+ schemaName,
+ tableName,
+ overwrite,
+ fromField,
+ List.copyOf(columns));
+ }
+
+ private static String firstNonBlank(String current, Object candidate) {
+ if (!StringUtils.isBlank(current) || !(candidate instanceof String s) || s.isBlank()) {
+ return current;
+ }
+ return s;
+ }
+ }
+
+ /** Only descends into Hop's own metadata classes, never into JDK or third-party types. */
+ private static boolean isMetadataObject(Object value) {
+ if (value == null) {
+ return false;
+ }
+ Class<?> type = value.getClass();
+ if (type.isPrimitive() || type.isEnum() || type.isArray()) {
+ return false;
+ }
+ Package pkg = type.getPackage();
+ return pkg != null && pkg.getName().toLowerCase(Locale.ROOT).startsWith("org.apache.hop");
+ }
+
+ private static Object readField(Field field, Object target) {
+ try {
+ field.setAccessible(true);
+ return field.get(target);
+ } catch (Exception e) {
+ // A field the JVM will not let us read simply contributes nothing.
+ return null;
+ }
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/LineageRelationalIdentity.java b/engine/src/main/java/org/apache/hop/lineage/LineageRelationalIdentity.java
new file mode 100644
index 0000000000..615e0552ad
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/LineageRelationalIdentity.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.lineage.model.RelationalTable;
+
+/**
+ * Single source of truth for the OpenLineage relational dataset identity documented on the
+ * "OpenLineage dataset identity" page of the user manual. Lives in the engine (not the sink)
+ * because computing the {@code namespace} needs the {@link DatabaseMeta} the plugin never sees, and
+ * because a Table Output (known table) and a parsed Table Input {@code SELECT} must produce a
+ * byte-identical identity for the same physical table.
+ *
+ * <p>Namespace (§3.1) is {@code scheme://host:port}; the scheme is mapped from the Hop database
+ * type (not the raw JDBC sub-protocol, which differs — Postgres is {@code postgresql} in JDBC but
+ * {@code postgres} in the OpenLineage naming spec). Name (§3.2) is {@code
+ * {database}.{schema}.{table}} with only the segments the database has. Casing is the caller's
+ * responsibility: segments must be supplied exactly as the database stores them so both halves of a
+ * stitch agree.
+ */
+public final class LineageRelationalIdentity {
+
+ /**
+ * Hop database type ({@code DatabaseMeta.getPluginId()}) → OpenLineage naming-spec scheme. Types
+ * absent here fall back to the lowercased Hop type id, matching the contract's "Generic JDBC"
+ * row.
+ */
+ private static final Map<String, String> SCHEME_BY_TYPE =
+ Map.ofEntries(
+ Map.entry("POSTGRESQL", "postgres"),
+ Map.entry("MYSQL", "mysql"),
+ Map.entry("MARIADB", "mysql"),
+ Map.entry("REDSHIFT", "redshift"),
+ Map.entry("ORACLE", "oracle"),
+ Map.entry("MSSQL", "mssql"),
+ Map.entry("MSSQLNATIVE", "mssql"),
+ Map.entry("DB2", "db2"));
+
+ private LineageRelationalIdentity() {}
+
+ /**
+ * OpenLineage dataset namespace for the given connection, or {@code null} when there is no host
+ * to key on (e.g. embedded/file databases, which this phase does not identify as relational
+ * sources).
+ */
+ public static String namespace(DatabaseMeta databaseMeta, IVariables variables) {
+ if (databaseMeta == null) {
+ return null;
+ }
+ String host = resolve(variables, databaseMeta.getHostname());
+ String port = resolve(variables, databaseMeta.getPort());
+ return buildNamespace(databaseMeta.getPluginId(), host, port, defaultPortOrZero(databaseMeta));
+ }
+
+ /**
+ * Pure core of {@link #namespace}: builds {@code scheme://host[:port]} from already-resolved
+ * parts. Package-visible so the contract rules can be unit-tested without a live {@link
+ * DatabaseMeta}. Returns {@code null} when {@code host} is blank.
+ */
+ static String buildNamespace(String hopTypeId, String host, String port, int defaultPort) {
+ if (StringUtils.isBlank(host)) {
+ return null;
+ }
+ String scheme = schemeFor(hopTypeId);
+ String effectivePort = StringUtils.isBlank(port) ? portString(defaultPort) : port.trim();
+ StringBuilder ns =
+ new StringBuilder(scheme).append("://").append(host.trim().toLowerCase(Locale.ROOT));
+ if (!StringUtils.isBlank(effectivePort)) {
+ ns.append(':').append(effectivePort);
+ }
+ return ns.toString();
+ }
+
+ /**
+ * Fully qualified dataset name {@code {database}.{schema}.{table}} (§3.2): the present segments
+ * joined with {@code .}, verbatim (no re-casing, no quoting). Returns {@code null} when the table
+ * is blank.
+ */
+ public static String datasetName(RelationalTable table) {
+ if (table == null || StringUtils.isBlank(table.getTable())) {
+ return null;
+ }
+ StringBuilder name = new StringBuilder();
+ appendSegment(name, table.getDatabase());
+ appendSegment(name, table.getSchema());
+ appendSegment(name, table.getTable());
+ return name.toString();
+ }
+
+ private static void appendSegment(StringBuilder name, String segment) {
+ if (StringUtils.isBlank(segment)) {
+ return;
+ }
+ if (name.length() > 0) {
+ name.append('.');
+ }
+ name.append(segment.trim());
+ }
+
+ /**
+ * Qualifies a table with the connection's catalog when it has none. Tables recovered by parsing a
+ * {@code SELECT} carry no catalog segment (SQL cannot name it), so a read of {@code schema.table}
+ * would not match a write of {@code catalog.schema.table} for the same table. Filling the blank
+ * catalog with the connection's database — which both sides share — makes the two identities
+ * agree. Tables that already carry a catalog, and blank {@code defaultCatalog}, are returned
+ * unchanged.
+ */
+ public static RelationalTable withDefaultCatalog(RelationalTable table, String defaultCatalog) {
+ return withDefaults(table, defaultCatalog, null);
+ }
+
+ /**
+ * Fills a table's blank catalog and/or schema from the connection defaults so that tables named
+ * at different levels of qualification (a bare {@code table} in a {@code SELECT}, a {@code
+ * schema.table} write) resolve to the same {@code catalog.schema.table} identity. Segments that
+ * are already present, and blank defaults, are left untouched.
+ */
+ public static RelationalTable withDefaults(
+ RelationalTable table, String defaultCatalog, String defaultSchema) {
+ if (table == null) {
+ return null;
+ }
+ String database =
+ StringUtils.isBlank(table.getDatabase()) && StringUtils.isNotBlank(defaultCatalog)
+ ? defaultCatalog.trim()
+ : table.getDatabase();
+ String schema =
+ StringUtils.isBlank(table.getSchema()) && StringUtils.isNotBlank(defaultSchema)
+ ? defaultSchema.trim()
+ : table.getSchema();
+ if (Objects.equals(database, table.getDatabase())
+ && Objects.equals(schema, table.getSchema())) {
+ return table;
+ }
+ return new RelationalTable(database, schema, table.getTable());
+ }
+
+ private static String schemeFor(String hopTypeId) {
+ if (StringUtils.isBlank(hopTypeId)) {
+ return "jdbc";
+ }
+ String upper = hopTypeId.trim().toUpperCase(Locale.ROOT);
+ return SCHEME_BY_TYPE.getOrDefault(upper, upper.toLowerCase(Locale.ROOT));
+ }
+
+ private static int defaultPortOrZero(DatabaseMeta databaseMeta) {
+ try {
+ return databaseMeta.getDefaultDatabasePort();
+ } catch (RuntimeException e) {
+ // Some IDatabase implementations throw for portless (embedded) databases.
+ return 0;
+ }
+ }
+
+ private static String portString(int port) {
+ return port > 0 ? Integer.toString(port) : null;
+ }
+
+ private static String resolve(IVariables variables, String raw) {
+ if (raw == null) {
+ return null;
+ }
+ return variables == null ? raw : variables.resolve(raw);
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/LineageRelationalIoEmitter.java b/engine/src/main/java/org/apache/hop/lineage/LineageRelationalIoEmitter.java
new file mode 100644
index 0000000000..8646f1583e
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/LineageRelationalIoEmitter.java
@@ -0,0 +1,534 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hop.base.AbstractMeta;
+import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.row.IRowMeta;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.util.Utils;
+import org.apache.hop.lineage.context.LineageContext;
+import org.apache.hop.lineage.hub.LineageHub;
+import org.apache.hop.lineage.model.FileIoContentSchema;
+import org.apache.hop.lineage.model.FileIoTabularColumn;
+import org.apache.hop.lineage.model.LineageEvent;
+import org.apache.hop.lineage.model.LineageEventKind;
+import org.apache.hop.lineage.model.RelationalIoLineagePayload;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.apache.hop.lineage.model.RelationalLifecycle;
+import org.apache.hop.lineage.model.RelationalTable;
+import org.apache.hop.lineage.model.RelationalWriteColumn;
+import org.apache.hop.pipeline.transform.ITransform;
+
+/**
+ * Emits {@link LineageEventKind#RELATIONAL_IO} observations to {@link LineageHub} so sinks can
+ * record which relational tables a transform read from or wrote to. The physical dataset identity
+ * (the OpenLineage {@code namespace}) is resolved here — engine-side — from the {@link
+ * DatabaseMeta} because the plugin never sees a connection; see {@link LineageRelationalIdentity}
+ * and the "OpenLineage dataset identity" page of the Hop user manual (relational datasets).
+ *
+ * <p>Four shapes are supported:
+ *
+ * <ul>
+ * <li><b>write</b> — a transform whose target table is known up front (e.g. Table Output,
+ * Insert/Update): {@link #emitTransformRelationalWrite}.
+ * <li><b>read</b> — a transform that reads via a {@code SELECT} whose source tables are not known
+ * to the engine (e.g. Table Input): {@link #emitTransformRelationalRead}. The raw SQL is
+ * carried on the payload for a sink to parse into input tables; callers that already know the
+ * tables may pass them directly.
+ * <li><b>delete</b> — a transform that removes rows from a known table (e.g. Delete): {@link
+ * #emitTransformRelationalDelete}. The table is affected but no columns are produced, so no
+ * column schema and no column provenance are carried.
+ * <li><b>exec</b> — arbitrary SQL that may read and write (e.g. Execute SQL): {@link
+ * #emitTransformRelationalExec}.
+ * </ul>
+ *
+ * <p><b>Best-effort by construction.</b> Every method is a no-op when its required arguments are
+ * null and <b>never throws into transform execution</b>: the whole emission path is guarded here,
+ * so call sites invoke these methods directly without a defensive {@code try/catch} of their own. A
+ * failure is logged on the transform's own log channel at debug level and otherwise ignored.
+ */
+public final class LineageRelationalIoEmitter {
+
+ /** Format hint stored on the row schema of a relational dataset. */
+ private static final String JDBC_FORMAT_HINT = "jdbc";
+
+ private LineageRelationalIoEmitter() {}
+
+ /**
+ * Records a write to a known relational table (Table Output and similar). {@code database} and
+ * {@code schema} may be null/blank for databases without those levels; {@code table} is required.
+ *
+ * @param transform the transform performing the write (must not be null)
+ * @param databaseMeta the target connection (must not be null; supplies the dataset namespace)
+ * @param database catalog/database segment, or null/blank when not applicable
+ * @param schema schema segment, or null/blank when not applicable
+ * @param table target table name (required)
+ * @param writtenRowMeta row shape written to the table, for a column schema; may be null
+ * @param success whether the write completed without error
+ * @param message optional short detail (failure reason, etc.)
+ */
+ public static void emitTransformRelationalWrite(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ String database,
+ String schema,
+ String table,
+ IRowMeta writtenRowMeta,
+ boolean success,
+ String message) {
+ emitTransformRelationalWrite(
+ transform, databaseMeta, database, schema, table, writtenRowMeta, null, success, message);
+ }
+
+ /**
+ * Same as {@link #emitTransformRelationalWrite(ITransform, DatabaseMeta, String, String, String,
+ * IRowMeta, boolean, String)} but with per-column provenance ({@code writeColumns}) so a sink can
+ * build column-level lineage for the pipeline stream path.
+ */
+ public static void emitTransformRelationalWrite(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ String database,
+ String schema,
+ String table,
+ IRowMeta writtenRowMeta,
+ List<RelationalWriteColumn> writeColumns,
+ boolean success,
+ String message) {
+ emitTransformRelationalWrite(
+ transform,
+ databaseMeta,
+ database,
+ schema,
+ table,
+ writtenRowMeta,
+ writeColumns,
+ null,
+ success,
+ message);
+ }
+
+ /**
+ * Same as the {@code writeColumns} overload but also records the lifecycle state the write
+ * applied to its target (e.g. {@link RelationalLifecycle#OVERWRITE} when the target was truncated
+ * first).
+ */
+ public static void emitTransformRelationalWrite(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ String database,
+ String schema,
+ String table,
+ IRowMeta writtenRowMeta,
+ List<RelationalWriteColumn> writeColumns,
+ RelationalLifecycle lifecycle,
+ boolean success,
+ String message) {
+ if (transform == null || databaseMeta == null || Utils.isEmpty(table)) {
+ return;
+ }
+ emit(
+ transform,
+ databaseMeta,
+ RelationalIoOperation.WRITE,
+ null,
+ List.of(),
+ List.of(new RelationalTable(database, schema, table)),
+ toContentSchema(writtenRowMeta),
+ writeColumns,
+ lifecycle,
+ success,
+ message);
+ }
+
+ /**
+ * Records a read performed by a {@code SELECT} (Table Input and similar). When the engine cannot
+ * resolve the source tables it passes {@code inputs = null} and relies on a sink to parse {@code
+ * sql}; callers that already know the tables may pass them in {@code inputs}.
+ *
+ * @param transform the transform performing the read (must not be null)
+ * @param databaseMeta the source connection (must not be null; supplies the dataset namespace)
+ * @param sql the SQL that produced the rows, retained for downstream table/column parsing
+ * @param inputs source tables when already known, or null/empty to defer to SQL parsing
+ * @param outputRowMeta row shape produced by the read, for a column schema; may be null
+ * @param success whether the read completed without error
+ * @param message optional short detail (failure reason, etc.)
+ */
+ public static void emitTransformRelationalRead(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ String sql,
+ List<RelationalTable> inputs,
+ IRowMeta outputRowMeta,
+ boolean success,
+ String message) {
+ if (transform == null || databaseMeta == null) {
+ return;
+ }
+ emit(
+ transform,
+ databaseMeta,
+ RelationalIoOperation.READ,
+ sql,
+ inputs,
+ List.of(),
+ toContentSchema(outputRowMeta),
+ success,
+ message);
+ }
+
+ /**
+ * Records a row deletion from a known relational table (Delete and similar). The table is
+ * reported as an affected output dataset, but — unlike a write — no column schema and no column
+ * provenance are carried: a delete produces no columns, so publishing the transform's input row
+ * shape as the target table's schema would be wrong.
+ *
+ * @param transform the transform performing the delete (must not be null)
+ * @param databaseMeta the target connection (must not be null; supplies the dataset namespace)
+ * @param database catalog/database segment, or null/blank when not applicable
+ * @param schema schema segment, or null/blank when not applicable
+ * @param table affected table name (required)
+ * @param success whether the delete completed without error
+ * @param message optional short detail (failure reason, etc.)
+ */
+ public static void emitTransformRelationalDelete(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ String database,
+ String schema,
+ String table,
+ boolean success,
+ String message) {
+ if (transform == null || databaseMeta == null || Utils.isEmpty(table)) {
+ return;
+ }
+ emit(
+ transform,
+ databaseMeta,
+ RelationalIoOperation.DELETE,
+ null,
+ List.of(),
+ List.of(new RelationalTable(database, schema, table)),
+ null,
+ success,
+ message);
+ }
+
+ /**
+ * Records arbitrary SQL that may read and/or write tables (Execute SQL and similar). Both table
+ * lists may be null/empty and left for a sink to resolve from {@code sql}.
+ *
+ * @param transform the transform running the SQL (must not be null)
+ * @param databaseMeta the connection the SQL runs on (must not be null)
+ * @param sql the SQL statement(s), retained for downstream table/column parsing
+ * @param inputs tables read when already known, or null/empty to defer to SQL parsing
+ * @param outputs tables written when already known, or null/empty to defer to SQL parsing
+ * @param success whether execution completed without error
+ * @param message optional short detail (failure reason, etc.)
+ */
+ public static void emitTransformRelationalExec(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ String sql,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ boolean success,
+ String message) {
+ if (transform == null || databaseMeta == null) {
+ return;
+ }
+ emit(
+ transform,
+ databaseMeta,
+ RelationalIoOperation.EXEC,
+ sql,
+ inputs,
+ outputs,
+ null,
+ success,
+ message);
+ }
+
+ private static void emit(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ RelationalIoOperation operation,
+ String sql,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ FileIoContentSchema outputSchema,
+ boolean success,
+ String message) {
+ emit(
+ transform,
+ databaseMeta,
+ operation,
+ sql,
+ inputs,
+ outputs,
+ outputSchema,
+ null,
+ null,
+ success,
+ message);
+ }
+
+ private static void emit(
+ ITransform transform,
+ DatabaseMeta databaseMeta,
+ RelationalIoOperation operation,
+ String sql,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ FileIoContentSchema outputSchema,
+ List<RelationalWriteColumn> writeColumns,
+ RelationalLifecycle lifecycle,
+ boolean success,
+ String message) {
+ // The single guard for the whole feature: lineage is an observation of the pipeline, never a
+ // participant in it, so nothing raised while building or queueing an event may surface to the
+ // transform. Keeping it here (rather than at every call site) is what lets the ~15 emit points
+ // across the transforms call these methods bare.
+ try {
+ LineageContext.Builder ctx = LineageRunLifecycleEmitter.transformContextBuilder(transform);
+ if (ctx == null) {
+ return;
+ }
+ if (!Utils.isEmpty(transform.getTransformPluginId())) {
+ ctx.putAttribute("transformPluginId", transform.getTransformPluginId());
+ }
+ // The transform is an IVariables; the identity helper resolves host/port against it.
+ String namespace = LineageRelationalIdentity.namespace(databaseMeta, transform);
+ // Connection catalog + preferred schema, used by a sink to qualify tables recovered from SQL
+ // (which may name neither) so reads and writes of the same table share one identity.
+ String defaultCatalog = transform.resolve(databaseMeta.getDatabaseName());
+ String defaultSchema = transform.resolve(databaseMeta.getPreferredSchemaName());
+ RelationalIoLineagePayload payload =
+ new RelationalIoLineagePayload(
+ operation,
+ namespace,
+ inputs,
+ outputs,
+ sql,
+ outputSchema,
+ defaultCatalog,
+ defaultSchema,
+ writeColumns,
+ lifecycle,
+ success,
+ message);
+ LineageHub.getInstance()
+ .emit(LineageEvent.of(LineageEventKind.RELATIONAL_IO, ctx.build(), payload));
+ } catch (Exception e) {
+ logLineageFailure(transform, e);
+ }
+ }
+
+ /**
+ * Emits the relational lineage a transform declares on its metadata, combining the static
+ * declaration read by {@link LineageMetadataWalker} with the facts only available at runtime:
+ * resolved variables, the connection the name refers to, the row shape, and the transform that
+ * produced each stream field.
+ *
+ * <p>This is the path taken for every transform annotated {@link
+ * org.apache.hop.lineage.api.RelationalLineage}, so a transform declares its table access once
+ * and emits nothing itself. A no-op when the transform declares nothing, when the declaration
+ * cannot produce a dataset identity, or when the target table is only known per row — the
+ * transform reports those targets itself.
+ *
+ * @param transform the transform being observed (must not be null)
+ * @param success whether the transform completed without error
+ */
+ public static void emitDeclaredRelationalIo(ITransform transform, boolean success) {
+ if (transform == null) {
+ return;
+ }
+ try {
+ LineageMetadataWalker.Declaration declared = LineageMetadataWalker.read(transform.getMeta());
+ if (declared == null || !declared.isUsable()) {
+ return;
+ }
+ DatabaseMeta databaseMeta =
+ lineageConnection(
+ transform, pipelineMetaOf(transform), transform.resolve(declared.connectionName()));
+ if (databaseMeta == null) {
+ return;
+ }
+ String catalog = transform.resolve(databaseMeta.getDatabaseName());
+ String schema = transform.resolve(declared.schemaName());
+ String table = transform.resolve(declared.tableName());
+ IRowMeta inputRowMeta = LineageTransformSchemaEmitter.resolveInputRowMetaRuntime(transform);
+
+ if (declared.operation() == RelationalIoOperation.DELETE) {
+ // A delete affects the table but produces no columns of its own.
+ emitTransformRelationalDelete(
+ transform, databaseMeta, catalog, schema, table, success, null);
+ return;
+ }
+
+ List<RelationalWriteColumn> columns = new ArrayList<>();
+ for (LineageMetadataWalker.ColumnMapping mapping : declared.columns()) {
+ addWriteColumn(
+ columns,
+ inputRowMeta,
+ transform.resolve(mapping.targetColumn()),
+ transform.resolve(mapping.streamField()));
+ }
+ // No declared mapping means the whole input row is written 1:1 under its own names.
+ if (columns.isEmpty()) {
+ columns = writeColumnsFromRow(inputRowMeta);
+ }
+ emitTransformRelationalWrite(
+ transform,
+ databaseMeta,
+ catalog,
+ schema,
+ table,
+ inputRowMeta,
+ columns,
+ declared.overwrite() ? RelationalLifecycle.OVERWRITE : null,
+ success,
+ null);
+ } catch (Exception e) {
+ logLineageFailure(transform, e);
+ }
+ }
+
+ /**
+ * Resolves a named connection for lineage without letting a lookup failure reach the transform.
+ * Transforms that do not otherwise hold a {@link DatabaseMeta} at emit time (the bulk loaders,
+ * which open a native client rather than a JDBC connection) use this instead of calling {@code
+ * findDatabase} themselves inside a defensive block.
+ *
+ * @return the connection, or null when it cannot be resolved (lineage is then skipped)
+ */
+ public static DatabaseMeta lineageConnection(
+ ITransform transform, AbstractMeta meta, String connectionName) {
+ if (transform == null || meta == null || Utils.isEmpty(connectionName)) {
+ return null;
+ }
+ try {
+ return meta.findDatabase(connectionName, transform);
+ } catch (Exception e) {
+ logLineageFailure(transform, e);
+ return null;
+ }
+ }
+
+ /** The pipeline a transform belongs to, or null when it cannot be reached. */
+ private static AbstractMeta pipelineMetaOf(ITransform transform) {
+ try {
+ return transform.getPipeline() == null ? null : transform.getPipeline().getPipelineMeta();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /** Reports a swallowed lineage failure on the transform's own channel, at debug level only. */
+ private static void logLineageFailure(ITransform transform, Exception e) {
+ try {
+ ILogChannel log = transform.getLogChannel();
+ if (log != null && log.isDebug()) {
+ log.logDebug("Relational lineage observation skipped: " + e.getMessage());
+ }
+ } catch (Exception ignored) {
+ // The logger itself failed; there is nowhere left to report to.
+ }
+ }
+
+ /**
+ * Converts a Hop {@link IRowMeta} to the neutral {@link FileIoContentSchema} carried on
+ * relational events, so a sink can populate OpenLineage dataset {@code schema} fields (column
+ * name + Hop type). Returns null for a null/empty row shape. Relational columns have no path
+ * locator, so the structure-roots tree is empty.
+ */
+ static FileIoContentSchema toContentSchema(IRowMeta rowMeta) {
+ if (rowMeta == null || rowMeta.isEmpty()) {
+ return null;
+ }
+ List<FileIoTabularColumn> columns = new ArrayList<>(rowMeta.size());
+ for (IValueMeta valueMeta : rowMeta.getValueMetaList()) {
+ columns.add(
+ new FileIoTabularColumn(
+ valueMeta.getName(),
+ valueMeta.getTypeDesc(),
+ valueMeta.getLength(),
+ valueMeta.getPrecision(),
+ null,
+ null,
+ false));
+ }
+ return new FileIoContentSchema(JDBC_FORMAT_HINT, columns, List.of());
+ }
+
+ /**
+ * Builds one column-provenance entry for {@link #emitTransformRelationalWrite}: maps {@code
+ * streamField} to {@code targetColumn} (falling back to the stream field name when the target is
+ * blank) and resolves the transform that produced the field via {@link IValueMeta#getOrigin()} so
+ * a sink can trace the column back to its source. Returns {@code null} — for the caller to skip —
+ * when there is no row shape or no stream field (e.g. a generated column with no input).
+ */
+ public static RelationalWriteColumn writeColumn(
+ IRowMeta inputRowMeta, String targetColumn, String streamField) {
+ if (inputRowMeta == null || Utils.isEmpty(streamField)) {
+ return null;
+ }
+ IValueMeta valueMeta = inputRowMeta.searchValueMeta(streamField);
+ return new RelationalWriteColumn(
+ Utils.isEmpty(targetColumn) ? streamField : targetColumn,
+ streamField,
+ valueMeta != null ? valueMeta.getOrigin() : null);
+ }
+
+ /**
+ * Convenience over {@link #writeColumn}: appends the resolved column provenance to {@code
+ * columns}, skipping it when the stream field is blank or the row shape is unavailable. Lets a
+ * transform map its field list to write columns without null-check boilerplate.
+ */
+ public static void addWriteColumn(
+ List<RelationalWriteColumn> columns,
+ IRowMeta inputRowMeta,
+ String targetColumn,
+ String streamField) {
+ RelationalWriteColumn column = writeColumn(inputRowMeta, targetColumn, streamField);
+ if (column != null) {
+ columns.add(column);
+ }
+ }
+
+ /**
+ * Column provenance for a transform that writes its whole input row 1:1 (target column name
+ * equals the stream field name) — e.g. a bulk loader with no explicit field mapping. Returns an
+ * empty list for a null/empty row shape.
+ */
+ public static List<RelationalWriteColumn> writeColumnsFromRow(IRowMeta inputRowMeta) {
+ List<RelationalWriteColumn> columns = new ArrayList<>();
+ if (inputRowMeta != null) {
+ for (IValueMeta valueMeta : inputRowMeta.getValueMetaList()) {
+ columns.add(
+ new RelationalWriteColumn(
+ valueMeta.getName(), valueMeta.getName(), valueMeta.getOrigin()));
+ }
+ }
+ return columns;
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/LineageTransformSchemaEmitter.java b/engine/src/main/java/org/apache/hop/lineage/LineageTransformSchemaEmitter.java
index fccfe50d34..4c5a713a40 100644
--- a/engine/src/main/java/org/apache/hop/lineage/LineageTransformSchemaEmitter.java
+++ b/engine/src/main/java/org/apache/hop/lineage/LineageTransformSchemaEmitter.java
@@ -165,7 +165,11 @@ public final class LineageTransformSchemaEmitter {
return List.copyOf(fields);
}
- private static IRowMeta resolveInputRowMetaRuntime(ITransform transform) {
+ /**
+ * The row shape a transform actually saw, preferring the live input row meta and falling back to
+ * its input row sets. Package-visible so the relational emitter resolves it identically.
+ */
+ static IRowMeta resolveInputRowMetaRuntime(ITransform transform) {
if (transform instanceof BaseTransform base) {
IRowMeta meta = base.getInputRowMeta();
if (meta != null && !meta.isEmpty()) {
diff --git a/engine/src/main/java/org/apache/hop/lineage/LineageVariables.java b/engine/src/main/java/org/apache/hop/lineage/LineageVariables.java
index ae88b799f3..bc78101875 100644
--- a/engine/src/main/java/org/apache/hop/lineage/LineageVariables.java
+++ b/engine/src/main/java/org/apache/hop/lineage/LineageVariables.java
@@ -17,14 +17,45 @@
package org.apache.hop.lineage;
+import org.apache.hop.core.variables.IVariables;
import org.apache.hop.core.variables.Variable;
import org.apache.hop.core.variables.VariableScope;
+import org.apache.hop.core.variables.Variables;
/** Hop variables that configure the lineage observation hub and sinks. */
public final class LineageVariables {
+ /** Prefix shared by every lineage hub and sink configuration variable. */
+ private static final String LINEAGE_PREFIX = "HOP_LINEAGE";
+
private LineageVariables() {}
+ /**
+ * Variable space used to resolve the engine-scoped lineage settings (hub configuration and sink
+ * plugin settings), with {@code HOP_LINEAGE_*} OS environment variables overlaid so they can be
+ * injected via Docker, Kubernetes or CI — the documented deployment path.
+ *
+ * <p>The environment is overlaid <b>unconditionally</b> for these keys, on purpose: {@code
+ * HopEnvironment} publishes the described ENGINE-variable <i>defaults</i> (e.g. {@code
+ * HOP_LINEAGE_ENABLED=N}) as JVM system properties during initialization, which {@link
+ * Variables#initializeFrom} then loads. A plain "only when not already a system property" overlay
+ * would therefore always lose to that default and the environment would be silently ignored. For
+ * the {@code HOP_LINEAGE_*} settings the environment wins over the system-property default; this
+ * is scoped to that prefix so no other variables are affected.
+ */
+ public static IVariables engineVariables() {
+ Variables variables = new Variables();
+ variables.initializeFrom(null);
+ System.getenv()
+ .forEach(
+ (key, value) -> {
+ if (key.startsWith(LINEAGE_PREFIX)) {
+ variables.setVariable(key, value);
+ }
+ });
+ return variables;
+ }
+
@Variable(
scope = VariableScope.ENGINE,
value = "N",
diff --git a/engine/src/main/java/org/apache/hop/lineage/api/RelationalLineage.java b/engine/src/main/java/org/apache/hop/lineage/api/RelationalLineage.java
new file mode 100644
index 0000000000..5294ceb4f6
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/api/RelationalLineage.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+
+/**
+ * Declares that a transform's metadata describes relational (JDBC) table access, so the engine can
+ * derive lineage from the {@code RDBMS_*} property annotations on that metadata instead of the
+ * transform emitting events itself.
+ *
+ * <p>Placed on the {@code ITransformMeta} class. The annotated metadata is expected to carry, via
+ * {@link org.apache.hop.metadata.api.HopMetadataPropertyType}:
+ *
+ * <ul>
+ * <li>{@code RDBMS_CONNECTION} — the connection name (required; without it there is no dataset
+ * namespace and nothing is emitted)
+ * <li>{@code RDBMS_TABLE}, optionally {@code RDBMS_SCHEMA} — the target/source table
+ * <li>{@code RDBMS_COLUMN} paired with {@code STREAM_FIELD} on the same mapping object —
+ * per-column provenance. Columns declaring no source (a generated technical key, for example)
+ * are simply left out of the column lineage.
+ * <li>{@code RDBMS_TRUNCATE} — a boolean, or a string whose value is matched against {@link
+ * #overwriteWhen()}, marking the write as replacing the target's contents
+ * </ul>
+ *
+ * <p>Opting in is deliberately explicit rather than inferred from the presence of {@code
+ * RDBMS_TABLE}: plenty of metadata names a table without reading or writing its rows (checking that
+ * it exists, comparing two of them, describing a column to look for), and emitting dataset lineage
+ * for those would be wrong.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface RelationalLineage {
+
+ /** What the transform does to the declared table. */
+ RelationalIoOperation operation();
+
+ /**
+ * Property values of a string-typed {@code RDBMS_TRUNCATE} that mean "the target now holds only
+ * this run's rows" — e.g. a bulk loader whose load action is {@code TRUNCATE} or {@code REPLACE}.
+ * Ignored for a boolean {@code RDBMS_TRUNCATE}, where {@code true} carries the same meaning.
+ */
+ String[] overwriteWhen() default {};
+
+ /**
+ * Name of the metadata property holding a <i>field name</i> whose row value supplies the table at
+ * runtime, rather than a literal table name. When set and populated, the declared {@code
+ * RDBMS_TABLE} is not a real table and no lineage is derived from metadata alone — the transform
+ * reports its actual targets itself.
+ */
+ String tableNameFromFieldProperty() default "";
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/hub/LineageConfiguration.java b/engine/src/main/java/org/apache/hop/lineage/hub/LineageConfiguration.java
index e62c876956..0f4ae6e85c 100644
--- a/engine/src/main/java/org/apache/hop/lineage/hub/LineageConfiguration.java
+++ b/engine/src/main/java/org/apache/hop/lineage/hub/LineageConfiguration.java
@@ -27,13 +27,15 @@ import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
-import org.apache.hop.core.variables.Variables;
import org.apache.hop.lineage.LineageVariables;
/** Effective lineage hub settings resolved from Hop variables. */
@Getter
public final class LineageConfiguration {
+ /** Memoized result of {@link #resolve()}; see that method for why. */
+ private static volatile LineageConfiguration cached;
+
private final boolean enabled;
private final int queueCapacity;
private final int batchMax;
@@ -60,10 +62,34 @@ public final class LineageConfiguration {
return new LineageConfiguration(enabled, queueCapacity, batchMax, batchLingerMs, sinkIds);
}
+ /**
+ * The effective configuration, memoized.
+ *
+ * <p>Resolving is not cheap — {@link LineageVariables#engineVariables()} builds a fresh variable
+ * space from every system property and described variable, then overlays the environment — and
+ * {@link LineageHub#emit} consults it for <b>every</b> event, including the disabled-by-default
+ * fast path. These are ENGINE-scoped settings read once per JVM at startup, so they cannot change
+ * under a running engine; caching the resolved value turns that per-event cost into a one-off.
+ * {@link #invalidate()} drops the cache when the environment is (re)initialized.
+ */
public static LineageConfiguration resolve() {
- Variables variables = new Variables();
- variables.initializeFrom(null);
- return resolve(variables);
+ LineageConfiguration current = cached;
+ if (current != null) {
+ return current;
+ }
+ synchronized (LineageConfiguration.class) {
+ if (cached == null) {
+ cached = resolve(LineageVariables.engineVariables());
+ }
+ return cached;
+ }
+ }
+
+ /** Drops the memoized configuration so the next {@link #resolve()} re-reads the variables. */
+ public static void invalidate() {
+ synchronized (LineageConfiguration.class) {
+ cached = null;
+ }
}
public static LineageConfiguration resolve(IVariables variables) {
diff --git a/engine/src/main/java/org/apache/hop/lineage/hub/LineageHub.java b/engine/src/main/java/org/apache/hop/lineage/hub/LineageHub.java
index 3239811601..2d3eed67d6 100644
--- a/engine/src/main/java/org/apache/hop/lineage/hub/LineageHub.java
+++ b/engine/src/main/java/org/apache/hop/lineage/hub/LineageHub.java
@@ -32,7 +32,8 @@ import org.apache.hop.core.logging.ILogChannel;
import org.apache.hop.core.logging.LogChannel;
import org.apache.hop.core.plugins.IPlugin;
import org.apache.hop.core.plugins.PluginRegistry;
-import org.apache.hop.core.variables.Variables;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.lineage.LineageVariables;
import org.apache.hop.lineage.model.LineageEvent;
import org.apache.hop.lineage.plugin.LineageSinkPluginType;
import org.apache.hop.lineage.spi.ILineageSink;
@@ -85,10 +86,20 @@ public final class LineageHub {
/** Invoked after {@link org.apache.hop.core.HopEnvironment} finishes plugin registration. */
public void environmentReady() {
+ LineageConfiguration.invalidate();
sinksInitialized.set(false);
sinks = List.of();
}
+ /**
+ * Whether lineage observation is switched on. Callers that would do measurable work purely to
+ * build an event — e.g. accumulating per-row state — should check this first; it is a cheap read
+ * of the memoized configuration.
+ */
+ public boolean isEnabled() {
+ return resolveConfig().isEnabled();
+ }
+
/**
* Queue a lineage event. No-op when lineage is disabled. Drops the event when the queue is full
* and increments an internal drop counter.
@@ -155,6 +166,7 @@ public final class LineageHub {
shutdownSinks();
sinksInitialized.set(false);
sinks = List.of();
+ LineageConfiguration.invalidate();
}
/**
@@ -316,8 +328,7 @@ public final class LineageHub {
if (sinksInitialized.get()) {
return;
}
- Variables variables = new Variables();
- variables.initializeFrom(null);
+ IVariables variables = LineageVariables.engineVariables();
if (explicitSinks != null) {
sinks = List.copyOf(explicitSinks);
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java b/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
index b75944821e..fc22ad7d04 100644
--- a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
+++ b/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
@@ -24,5 +24,7 @@ public enum LineageEventKind {
TRANSFORM_SCHEMA,
FILE_IO,
/** HTTP client traffic from transforms/actions (payload: {@link HttpLineagePayload}). */
- HTTP_IO
+ HTTP_IO,
+ /** Relational/JDBC table read or write (payload: {@link RelationalIoLineagePayload}). */
+ RELATIONAL_IO
}
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/RelationalIoLineagePayload.java b/engine/src/main/java/org/apache/hop/lineage/model/RelationalIoLineagePayload.java
new file mode 100644
index 0000000000..b2c4b28955
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/model/RelationalIoLineagePayload.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import lombok.Getter;
+
+/**
+ * Relational/JDBC read or write observed on a transform, carrying the input and output tables that
+ * a sink maps to OpenLineage datasets.
+ *
+ * <p>The {@code datasetNamespace} is resolved engine-side from the {@code DatabaseMeta} (via {@code
+ * LineageRelationalIdentity}) because the plugin never sees a connection; combined with each {@link
+ * RelationalTable}'s qualified name it forms the locked {@code (namespace, name)} identity of the
+ * "OpenLineage dataset identity" page of the user manual. {@code sqlText} is retained for a SQL job
+ * facet and, in a later phase, for column-level lineage parsing. {@code outputSchema} carries
+ * column names/Hop types when the transform knows its row shape (e.g. Table Input's {@code
+ * outputRowMeta}).
+ */
+@Getter
+public final class RelationalIoLineagePayload implements LineagePayload {
+
+ private final RelationalIoOperation operation;
+
+ /** OpenLineage dataset namespace of the database, e.g. {@code postgres://db:5432}. */
+ private final String datasetNamespace;
+
+ private final List<RelationalTable> inputs;
+ private final List<RelationalTable> outputs;
+
+ /** Raw SQL that produced this event, when available (Table Input, Execute SQL); may be null. */
+ private final String sqlText;
+
+ /** Column schema of the produced/consumed rows when known; may be null. */
+ private final FileIoContentSchema outputSchema;
+
+ /**
+ * Catalog/database of the connection ({@code DatabaseMeta.getDatabaseName()}), used by a sink to
+ * qualify tables recovered by parsing SQL: a {@code SELECT ... FROM schema.table} yields no
+ * catalog segment (SQL cannot name it), so the sink prepends this so a read and a write of the
+ * same table share one {@code database.schema.table} identity. Null/blank when the database has
+ * no catalog level.
+ */
+ private final String defaultCatalog;
+
+ /**
+ * Default schema of the connection ({@code DatabaseMeta.getPreferredSchemaName()}), used by a
+ * sink to fill a table's blank schema so a bare {@code table} in a {@code SELECT} resolves to the
+ * same {@code schema.table} identity as an explicitly schema-qualified write. Null/blank when the
+ * connection has no preferred schema.
+ */
+ private final String defaultSchema;
+
+ /**
+ * Per-column provenance of a write (target column, stream field, origin transform), used by a
+ * sink to build column-level lineage for the pipeline stream path. Empty for reads and for writes
+ * whose columns could not be traced.
+ */
+ private final List<RelationalWriteColumn> writeColumns;
+
+ /**
+ * Lifecycle state the write applied to its target (e.g. OVERWRITE on truncate); null when none.
+ */
+ private final RelationalLifecycle lifecycle;
+
+ private final boolean success;
+ private final String message;
+
+ public RelationalIoLineagePayload(
+ RelationalIoOperation operation,
+ String datasetNamespace,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ String sqlText,
+ FileIoContentSchema outputSchema,
+ boolean success,
+ String message) {
+ this(
+ operation,
+ datasetNamespace,
+ inputs,
+ outputs,
+ sqlText,
+ outputSchema,
+ null,
+ success,
+ message);
+ }
+
+ public RelationalIoLineagePayload(
+ RelationalIoOperation operation,
+ String datasetNamespace,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ String sqlText,
+ FileIoContentSchema outputSchema,
+ String defaultCatalog,
+ boolean success,
+ String message) {
+ this(
+ operation,
+ datasetNamespace,
+ inputs,
+ outputs,
+ sqlText,
+ outputSchema,
+ defaultCatalog,
+ null,
+ success,
+ message);
+ }
+
+ public RelationalIoLineagePayload(
+ RelationalIoOperation operation,
+ String datasetNamespace,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ String sqlText,
+ FileIoContentSchema outputSchema,
+ String defaultCatalog,
+ String defaultSchema,
+ boolean success,
+ String message) {
+ this(
+ operation,
+ datasetNamespace,
+ inputs,
+ outputs,
+ sqlText,
+ outputSchema,
+ defaultCatalog,
+ defaultSchema,
+ null,
+ success,
+ message);
+ }
+
+ public RelationalIoLineagePayload(
+ RelationalIoOperation operation,
+ String datasetNamespace,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ String sqlText,
+ FileIoContentSchema outputSchema,
+ String defaultCatalog,
+ String defaultSchema,
+ List<RelationalWriteColumn> writeColumns,
+ boolean success,
+ String message) {
+ this(
+ operation,
+ datasetNamespace,
+ inputs,
+ outputs,
+ sqlText,
+ outputSchema,
+ defaultCatalog,
+ defaultSchema,
+ writeColumns,
+ null,
+ success,
+ message);
+ }
+
+ public RelationalIoLineagePayload(
+ RelationalIoOperation operation,
+ String datasetNamespace,
+ List<RelationalTable> inputs,
+ List<RelationalTable> outputs,
+ String sqlText,
+ FileIoContentSchema outputSchema,
+ String defaultCatalog,
+ String defaultSchema,
+ List<RelationalWriteColumn> writeColumns,
+ RelationalLifecycle lifecycle,
+ boolean success,
+ String message) {
+ this.operation = Objects.requireNonNull(operation, "operation");
+ this.datasetNamespace = datasetNamespace;
+ this.inputs =
+ inputs == null ? List.of() : Collections.unmodifiableList(new ArrayList<>(inputs));
+ this.outputs =
+ outputs == null ? List.of() : Collections.unmodifiableList(new ArrayList<>(outputs));
+ this.sqlText = sqlText;
+ this.outputSchema = outputSchema;
+ this.defaultCatalog = defaultCatalog;
+ this.defaultSchema = defaultSchema;
+ this.writeColumns =
+ writeColumns == null
+ ? List.of()
+ : Collections.unmodifiableList(new ArrayList<>(writeColumns));
+ this.lifecycle = lifecycle;
+ this.success = success;
+ this.message = message;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ RelationalIoLineagePayload that = (RelationalIoLineagePayload) o;
+ return success == that.success
+ && operation == that.operation
+ && Objects.equals(datasetNamespace, that.datasetNamespace)
+ && inputs.equals(that.inputs)
+ && outputs.equals(that.outputs)
+ && Objects.equals(sqlText, that.sqlText)
+ && Objects.equals(outputSchema, that.outputSchema)
+ && Objects.equals(defaultCatalog, that.defaultCatalog)
+ && Objects.equals(defaultSchema, that.defaultSchema)
+ && writeColumns.equals(that.writeColumns)
+ && lifecycle == that.lifecycle
+ && Objects.equals(message, that.message);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ operation,
+ datasetNamespace,
+ inputs,
+ outputs,
+ sqlText,
+ outputSchema,
+ defaultCatalog,
+ defaultSchema,
+ writeColumns,
+ lifecycle,
+ success,
+ message);
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java b/engine/src/main/java/org/apache/hop/lineage/model/RelationalIoOperation.java
similarity index 59%
copy from engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
copy to engine/src/main/java/org/apache/hop/lineage/model/RelationalIoOperation.java
index b75944821e..348522e1c6 100644
--- a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
+++ b/engine/src/main/java/org/apache/hop/lineage/model/RelationalIoOperation.java
@@ -17,12 +17,17 @@
package org.apache.hop.lineage.model;
-/** High-level category of a lineage observation. */
-public enum LineageEventKind {
- RUN_LIFECYCLE,
- /** Transform input/output field names and Hop types (boundary schema). */
- TRANSFORM_SCHEMA,
- FILE_IO,
- /** HTTP client traffic from transforms/actions (payload: {@link HttpLineagePayload}). */
- HTTP_IO
+/** Relational/JDBC operation for {@link RelationalIoLineagePayload}. */
+public enum RelationalIoOperation {
+ /** Rows read from one or more tables (e.g. Table Input's {@code SELECT}). */
+ READ,
+ /** Rows written to a table (e.g. Table Output, Insert/Update). */
+ WRITE,
+ /**
+ * Rows removed from a table (e.g. Delete). The table is affected but no columns are produced, so
+ * events of this kind carry neither a column schema nor column provenance.
+ */
+ DELETE,
+ /** Arbitrary SQL whose read/write tables were resolved by parsing (e.g. Execute SQL). */
+ EXEC
}
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java b/engine/src/main/java/org/apache/hop/lineage/model/RelationalLifecycle.java
similarity index 57%
copy from engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
copy to engine/src/main/java/org/apache/hop/lineage/model/RelationalLifecycle.java
index b75944821e..57faeea472 100644
--- a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
+++ b/engine/src/main/java/org/apache/hop/lineage/model/RelationalLifecycle.java
@@ -17,12 +17,19 @@
package org.apache.hop.lineage.model;
-/** High-level category of a lineage observation. */
-public enum LineageEventKind {
- RUN_LIFECYCLE,
- /** Transform input/output field names and Hop types (boundary schema). */
- TRANSFORM_SCHEMA,
- FILE_IO,
- /** HTTP client traffic from transforms/actions (payload: {@link HttpLineagePayload}). */
- HTTP_IO
+/**
+ * Neutral lifecycle-state change a relational write applies to its target table, when the transform
+ * knows it. A sink maps these to the OpenLineage {@code LifecycleStateChangeDatasetFacet} (the
+ * names line up 1:1). Left {@code null} on the payload — the common case — when the write only
+ * appends rows and therefore changes no dataset-level state.
+ */
+public enum RelationalLifecycle {
+ /** The table's data was replaced (e.g. Table Output with "truncate table"). */
+ OVERWRITE,
+ /** The table was emptied. */
+ TRUNCATE,
+ /** The table was dropped. */
+ DROP,
+ /** The table was created. */
+ CREATE
}
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/RelationalTable.java b/engine/src/main/java/org/apache/hop/lineage/model/RelationalTable.java
new file mode 100644
index 0000000000..0dda0e9e54
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/model/RelationalTable.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.model;
+
+import java.util.Objects;
+import lombok.Getter;
+
+/**
+ * One relational table referenced by a {@link RelationalIoLineagePayload}, decomposed into the
+ * catalog/schema/table segments of the OpenLineage dataset-name contract (the "OpenLineage dataset
+ * identity" page of the user manual, {@code {database}.{schema}.{table}}).
+ *
+ * <p>Segments are stored verbatim as the database resolves them (no re-casing): the emitter is
+ * responsible for supplying them exactly as the database stores them in its catalog so both halves
+ * of a cross-tool stitch agree. {@code database} and {@code schema} are optional (a database
+ * without a catalog level supplies only schema+table); {@code table} is required. The qualified
+ * name is derived centrally by {@code LineageRelationalIdentity#datasetName} so the join rule lives
+ * in one place.
+ */
+@Getter
+public final class RelationalTable {
+
+ /** Catalog/database segment, or null/blank when the database has no catalog level. */
+ private final String database;
+
+ /** Schema segment, or null/blank when the database has no schema level. */
+ private final String schema;
+
+ /** Table (or view) name; required. */
+ private final String table;
+
+ public RelationalTable(String database, String schema, String table) {
+ this.database = database;
+ this.schema = schema;
+ this.table = Objects.requireNonNull(table, "table");
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ RelationalTable that = (RelationalTable) o;
+ return Objects.equals(database, that.database)
+ && Objects.equals(schema, that.schema)
+ && table.equals(that.table);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(database, schema, table);
+ }
+
+ @Override
+ public String toString() {
+ return "RelationalTable{"
+ + "database="
+ + database
+ + ", schema="
+ + schema
+ + ", table="
+ + table
+ + '}';
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/RelationalWriteColumn.java b/engine/src/main/java/org/apache/hop/lineage/model/RelationalWriteColumn.java
new file mode 100644
index 0000000000..705c4cd509
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/lineage/model/RelationalWriteColumn.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.model;
+
+import java.util.Objects;
+import lombok.Getter;
+
+/**
+ * Provenance of one column written by a relational transform (e.g. Table Output), used to build
+ * column-level lineage for the pipeline stream path. Carries the mapping from the input stream
+ * field to the target column, plus the {@code originTransform} — the name of the transform that
+ * produced the stream field ({@code IValueMeta.getOrigin()}). A sink correlates {@code
+ * originTransform} with the source-table read from the same transform to resolve {@code
+ * targetColumn} back to a source column, even through intervening pass-through transforms. Left
+ * {@code null}/blank when the origin is unknown, in which case no column lineage is inferred for
+ * the column.
+ */
+@Getter
+public final class RelationalWriteColumn {
+
+ /** Target table column name. */
+ private final String targetColumn;
+
+ /** Input stream field feeding the column. */
+ private final String streamField;
+
+ /** Name of the transform that produced the stream field, or null/blank when unknown. */
+ private final String originTransform;
+
+ public RelationalWriteColumn(String targetColumn, String streamField, String originTransform) {
+ this.targetColumn = targetColumn;
+ this.streamField = streamField;
+ this.originTransform = originTransform;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ RelationalWriteColumn that = (RelationalWriteColumn) o;
+ return Objects.equals(targetColumn, that.targetColumn)
+ && Objects.equals(streamField, that.streamField)
+ && Objects.equals(originTransform, that.originTransform);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(targetColumn, streamField, originTransform);
+ }
+
+ @Override
+ public String toString() {
+ return "RelationalWriteColumn{"
+ + "targetColumn="
+ + targetColumn
+ + ", streamField="
+ + streamField
+ + ", originTransform="
+ + originTransform
+ + '}';
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/xp/LineageHubTransformFinishXp.java b/engine/src/main/java/org/apache/hop/lineage/xp/LineageHubTransformFinishXp.java
index 77a88eb4e1..d635b1a898 100644
--- a/engine/src/main/java/org/apache/hop/lineage/xp/LineageHubTransformFinishXp.java
+++ b/engine/src/main/java/org/apache/hop/lineage/xp/LineageHubTransformFinishXp.java
@@ -22,6 +22,7 @@ import org.apache.hop.core.extension.ExtensionPoint;
import org.apache.hop.core.extension.IExtensionPoint;
import org.apache.hop.core.logging.ILogChannel;
import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.lineage.LineageRelationalIoEmitter;
import org.apache.hop.lineage.LineageRunLifecycleEmitter;
import org.apache.hop.lineage.LineageTransformSchemaEmitter;
import org.apache.hop.lineage.model.RunLifecyclePhase;
@@ -31,16 +32,23 @@ import org.apache.hop.pipeline.transform.TransformMetaDataCombi;
id = "LineageHubTransformFinishXp",
extensionPointId = "TransformFinished",
description =
- "Emits lineage RUN_LIFECYCLE FINISHED or FAILED when a transform has finished executing")
+ "Emits lineage RUN_LIFECYCLE FINISHED or FAILED when a transform has finished executing, "
+ + "plus the relational table access the transform declares on its metadata")
public class LineageHubTransformFinishXp implements IExtensionPoint<TransformMetaDataCombi> {
@Override
public void callExtensionPoint(
ILogChannel log, IVariables variables, TransformMetaDataCombi combi) throws HopException {
- RunLifecyclePhase phase =
- LineageRunLifecycleEmitter.transformFailed(combi)
- ? RunLifecyclePhase.FAILED
- : RunLifecyclePhase.FINISHED;
+ boolean failed = LineageRunLifecycleEmitter.transformFailed(combi);
+ RunLifecyclePhase phase = failed ? RunLifecyclePhase.FAILED : RunLifecyclePhase.FINISHED;
LineageRunLifecycleEmitter.emitTransform(combi, phase, null);
LineageTransformSchemaEmitter.emitTransformBoundarySchemas(combi);
+
+ // Relational lineage is derived from what the transform declares on its metadata rather than
+ // emitted by the transform itself, so every transform annotated @RelationalLineage is covered
+ // without needing its own emission code. Done at finish, where the row shape is populated and
+ // the outcome is known.
+ if (combi != null && combi.transform != null) {
+ LineageRelationalIoEmitter.emitDeclaredRelationalIo(combi.transform, !failed);
+ }
}
}
diff --git a/engine/src/test/java/org/apache/hop/lineage/LineageFileIdentityTest.java b/engine/src/test/java/org/apache/hop/lineage/LineageFileIdentityTest.java
new file mode 100644
index 0000000000..394f676a10
--- /dev/null
+++ b/engine/src/test/java/org/apache/hop/lineage/LineageFileIdentityTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.apache.hop.lineage.LineageFileIdentity.Identity;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Locks the OpenLineage file/object-store naming rules so a physical file yields one stable {@code
+ * (namespace, name)} identity regardless of which transform or engine emitted it.
+ */
+public class LineageFileIdentityTest {
+
+ @Test
+ public void localFileUsesFileNamespaceAndAbsolutePath() {
+ assertEquals(
+ new Identity("file", "/data/customers.csv"),
+ LineageFileIdentity.of("file:///data/customers.csv"));
+ }
+
+ @Test
+ public void s3BucketInNamespaceKeyWithoutLeadingSlash() {
+ assertEquals(
+ new Identity("s3://my-bucket", "warehouse/orders/part-0.parquet"),
+ LineageFileIdentity.of("s3://my-bucket/warehouse/orders/part-0.parquet"));
+ }
+
+ @Test
+ public void s3aAndS3nNormaliseToS3() {
+ assertEquals(new Identity("s3://b", "k.csv"), LineageFileIdentity.of("s3a://b/k.csv"));
+ assertEquals(new Identity("s3://b", "k.csv"), LineageFileIdentity.of("s3n://b/k.csv"));
+ }
+
+ @Test
+ public void gcsBucketInNamespace() {
+ assertEquals(
+ new Identity("gs://bkt", "path/to/file"), LineageFileIdentity.of("gs://bkt/path/to/file"));
+ }
+
+ @Test
+ public void hdfsHostPortInNamespacePathKept() {
+ assertEquals(
+ new Identity("hdfs://namenode:8020", "/warehouse/t/f"),
+ LineageFileIdentity.of("hdfs://namenode:8020/warehouse/t/f"));
+ }
+
+ @Test
+ public void azureContainerAndAccountKeptInNamespace() {
+ assertEquals(
+ new Identity("abfss://fs@acct.dfs.core.windows.net", "/dir/file"),
+ LineageFileIdentity.of("abfss://fs@acct.dfs.core.windows.net/dir/file"));
+ }
+
+ // Credentials in a URI must never leak into the lineage namespace.
+ @Test
+ public void userInfoIsStrippedFromGenericSchemes() {
+ assertEquals(
+ new Identity("sftp://host:22", "/upload/data.txt"),
+ LineageFileIdentity.of("sftp://user:secret@host:22/upload/data.txt"));
+ }
+
+ @Test
+ public void schemeWithoutHostFallsBackToScheme() {
+ assertEquals(new Identity("hdfs", "/p"), LineageFileIdentity.of("hdfs:/p"));
+ }
+
+ @Test
+ public void blankOrSchemelessOrUnparsableYieldsNull() {
+ assertNull(LineageFileIdentity.of(null));
+ assertNull(LineageFileIdentity.of(" "));
+ assertNull(LineageFileIdentity.of("/just/a/path"));
+ assertNull(LineageFileIdentity.of("::::"));
+ }
+
+ // The invariant: identity is a pure function of the URI, so the same physical file emitted by
+ // different transforms/engines reconciles onto one node.
+ @Test
+ public void sameUriAlwaysYieldsSameIdentity() {
+ String uri = "s3://bucket/key/file.parquet";
+ assertEquals(LineageFileIdentity.of(uri), LineageFileIdentity.of(uri));
+ }
+}
diff --git a/engine/src/test/java/org/apache/hop/lineage/LineageMetadataWalkerTest.java b/engine/src/test/java/org/apache/hop/lineage/LineageMetadataWalkerTest.java
new file mode 100644
index 0000000000..27154e661e
--- /dev/null
+++ b/engine/src/test/java/org/apache/hop/lineage/LineageMetadataWalkerTest.java
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.HopMetadataPropertyType;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Exercises the rules the walker applies to the {@code RDBMS_*} annotations. Uses purpose-built
+ * metadata shapes rather than real transform metadata so each rule is isolated; that the real
+ * transforms are annotated correctly is covered by their own module tests and the integration
+ * suite.
+ */
+class LineageMetadataWalkerTest {
+
+ /** A plain write: connection, schema and table on the meta, columns on a nested list. */
+ @RelationalLineage(operation = RelationalIoOperation.WRITE)
+ static class SimpleWriteMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_SCHEMA)
+ String schema = "staging";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+
+ @HopMetadataProperty String notes = "ignored";
+
+ @HopMetadataProperty List<Mapping> mappings = List.of(new Mapping("order_id", "id"));
+ }
+
+ static class Mapping {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
+ String stream;
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_COLUMN)
+ String column;
+
+ Mapping(String column, String stream) {
+ this.column = column;
+ this.stream = stream;
+ }
+ }
+
+ @Test
+ void readsConnectionSchemaTableAndColumnPairs() {
+ Declaration d = LineageMetadataWalker.read(new SimpleWriteMeta());
+
+ assertEquals(RelationalIoOperation.WRITE, d.operation());
+ assertEquals("warehouse", d.connectionName());
+ assertEquals("staging", d.schemaName());
+ assertEquals("orders", d.tableName());
+ assertTrue(d.isUsable());
+ assertEquals(List.of(new ColumnMapping("order_id", "id")), d.columns());
+ }
+
+ /** Metadata that does not opt in produces nothing, however many RDBMS properties it carries. */
+ static class UnannotatedMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+ }
+
+ @Test
+ void metadataWithoutTheClassAnnotationIsNotLineageBearing() {
+ assertNull(LineageMetadataWalker.read(new UnannotatedMeta()));
+ assertNull(LineageMetadataWalker.read(null));
+ }
+
+ /** The table and columns can live on a nested object, as they do for Insert/Update and Delete. */
+ @RelationalLineage(operation = RelationalIoOperation.DELETE)
+ static class NestedMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty Lookup lookup = new Lookup();
+ }
+
+ static class Lookup {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_SCHEMA)
+ String schema = "staging";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+
+ @HopMetadataProperty List<Mapping> keys = List.of(new Mapping("order_id", "id"));
+ }
+
+ @Test
+ void descendsIntoNestedMetadataObjects() {
+ Declaration d = LineageMetadataWalker.read(new NestedMeta());
+
+ assertEquals(RelationalIoOperation.DELETE, d.operation());
+ assertEquals("staging", d.schemaName());
+ assertEquals("orders", d.tableName());
+ assertEquals(1, d.columns().size());
+ }
+
+ /**
+ * A column with no declared source is generated by the transform — a dimension's technical key,
+ * for instance. It must not appear in the column lineage at all rather than appear sourceless.
+ */
+ @RelationalLineage(operation = RelationalIoOperation.WRITE)
+ static class GeneratedColumnMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "dim_customer";
+
+ @HopMetadataProperty List<Generated> generated = List.of(new Generated());
+
+ @HopMetadataProperty List<Mapping> mapped = List.of(new Mapping("name", "customer_name"));
+ }
+
+ static class Generated {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_COLUMN)
+ String technicalKey = "customer_tk";
+ }
+
+ @Test
+ void aColumnWithoutADeclaredSourceIsLeftOutOfColumnLineage() {
+ Declaration d = LineageMetadataWalker.read(new GeneratedColumnMeta());
+
+ assertEquals(List.of(new ColumnMapping("name", "customer_name")), d.columns());
+ }
+
+ /**
+ * A mapping object declaring two stream fields — the shape of a key mapping that also holds the
+ * second bound of a BETWEEN condition — cannot say which one feeds the column.
+ */
+ @RelationalLineage(operation = RelationalIoOperation.WRITE)
+ static class AmbiguousMappingMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+
+ @HopMetadataProperty List<AmbiguousMapping> mapped = List.of(new AmbiguousMapping());
+ }
+
+ static class AmbiguousMapping {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_COLUMN)
+ String column = "order_id";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
+ String from = "id_from";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
+ String to = "id_to";
+ }
+
+ @Test
+ void anAmbiguousMappingYieldsNoColumnLineageRatherThanAGuess() {
+ Declaration d = LineageMetadataWalker.read(new AmbiguousMappingMeta());
+
+ assertTrue(d.isUsable(), "the table identity is still declared");
+ assertTrue(
+ d.columns().isEmpty(),
+ "two stream fields on one mapping object must produce no column rather than the last one");
+ }
+
+ /** A boolean truncate marks the write as replacing the target. */
+ @RelationalLineage(operation = RelationalIoOperation.WRITE)
+ static class BooleanTruncateMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TRUNCATE)
+ boolean truncate = true;
+ }
+
+ @Test
+ void booleanTruncateIsAnOverwrite() {
+ assertTrue(LineageMetadataWalker.read(new BooleanTruncateMeta()).overwrite());
+ }
+
+ /** Loaders express the same thing as a load action; only the declared values count. */
+ @RelationalLineage(
+ operation = RelationalIoOperation.WRITE,
+ overwriteWhen = {"TRUNCATE", "REPLACE"})
+ static class LoadActionMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TRUNCATE)
+ String loadAction;
+
+ LoadActionMeta(String loadAction) {
+ this.loadAction = loadAction;
+ }
+ }
+
+ @Test
+ void loadActionIsAnOverwriteOnlyForTheDeclaredValues() {
+ assertTrue(LineageMetadataWalker.read(new LoadActionMeta("truncate")).overwrite());
+ assertTrue(LineageMetadataWalker.read(new LoadActionMeta("REPLACE")).overwrite());
+ assertFalse(LineageMetadataWalker.read(new LoadActionMeta("APPEND")).overwrite());
+ assertFalse(LineageMetadataWalker.read(new LoadActionMeta(null)).overwrite());
+ }
+
+ /**
+ * When the target table comes from a row field there is no table to name at design time, so the
+ * declaration is not usable and the transform reports its own targets instead.
+ */
+ @RelationalLineage(
+ operation = RelationalIoOperation.WRITE,
+ tableNameFromFieldProperty = "tableNameField")
+ static class DynamicTableMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "unused";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String tableNameField;
+
+ DynamicTableMeta(String tableNameField) {
+ this.tableNameField = tableNameField;
+ }
+ }
+
+ @Test
+ void aTableNameTakenFromARowFieldMakesTheDeclarationUnusable() {
+ assertFalse(LineageMetadataWalker.read(new DynamicTableMeta("target_table")).isUsable());
+ // With the field left blank the transform writes to its fixed table after all.
+ assertTrue(LineageMetadataWalker.read(new DynamicTableMeta("")).isUsable());
+ }
+
+ /** Without a connection there is no dataset namespace, so nothing can be emitted. */
+ @RelationalLineage(operation = RelationalIoOperation.WRITE)
+ static class NoConnectionMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+ }
+
+ @Test
+ void aDeclarationWithoutAConnectionIsNotUsable() {
+ assertFalse(LineageMetadataWalker.read(new NoConnectionMeta()).isUsable());
+ }
+
+ /** A cyclic metadata graph must terminate rather than hang or overflow. */
+ @RelationalLineage(operation = RelationalIoOperation.WRITE)
+ static class CyclicMeta {
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
+ String connection = "warehouse";
+
+ @HopMetadataProperty(hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
+ String table = "orders";
+
+ @HopMetadataProperty CyclicMeta self;
+ }
+
+ @Test
+ void aCyclicGraphTerminates() {
+ CyclicMeta meta = new CyclicMeta();
+ meta.self = meta;
+
+ Declaration d = LineageMetadataWalker.read(meta);
+ assertEquals("orders", d.tableName());
+ }
+}
diff --git a/engine/src/test/java/org/apache/hop/lineage/LineageRelationalIdentityTest.java b/engine/src/test/java/org/apache/hop/lineage/LineageRelationalIdentityTest.java
new file mode 100644
index 0000000000..5dff47969b
--- /dev/null
+++ b/engine/src/test/java/org/apache/hop/lineage/LineageRelationalIdentityTest.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.apache.hop.lineage.model.RelationalTable;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Locks the OpenLineage relational identity rules of the "OpenLineage dataset identity" page of the
+ * user manual so a regression here is caught before it silently splits a table into two lineage
+ * nodes.
+ */
+public class LineageRelationalIdentityTest {
+
+ // §3.1 — namespace scheme is mapped from the Hop database type, not the JDBC sub-protocol.
+ @Test
+ public void postgresNamespaceUsesSpecSchemeNotJdbcSubprotocol() {
+ assertEquals(
+ "postgres://db:5432",
+ LineageRelationalIdentity.buildNamespace("POSTGRESQL", "db", "5432", 5432));
+ }
+
+ @Test
+ public void mysqlAndMariaDbShareTheMysqlScheme() {
+ assertEquals(
+ "mysql://h:3306", LineageRelationalIdentity.buildNamespace("MYSQL", "h", "3306", 3306));
+ assertEquals(
+ "mysql://h:3306", LineageRelationalIdentity.buildNamespace("MARIADB", "h", "3306", 3306));
+ }
+
+ // §3.1 — host is lowercased so casing differences do not fork the namespace.
+ @Test
+ public void hostIsLowercasedAndTrimmed() {
+ assertEquals(
+ "postgres://prod-db:5432",
+ LineageRelationalIdentity.buildNamespace("POSTGRESQL", " PROD-DB ", " 5432 ", 5432));
+ }
+
+ // §3.1 — "any default port included explicitly when known": blank port falls back to the default.
+ @Test
+ public void blankPortFallsBackToDefaultPort() {
+ assertEquals(
+ "postgres://db:5432",
+ LineageRelationalIdentity.buildNamespace("POSTGRESQL", "db", "", 5432));
+ assertEquals(
+ "postgres://db:5432",
+ LineageRelationalIdentity.buildNamespace("POSTGRESQL", "db", null, 5432));
+ }
+
+ @Test
+ public void blankPortWithNoDefaultOmitsPort() {
+ assertEquals("generic://db", LineageRelationalIdentity.buildNamespace("GENERIC", "db", "", 0));
+ }
+
+ // §3.1 "Generic JDBC" row — unknown types fall back to the lowercased Hop type id as the scheme.
+ @Test
+ public void unknownTypeFallsBackToLowercasedTypeId() {
+ assertEquals(
+ "clickhouse://db:8123",
+ LineageRelationalIdentity.buildNamespace("CLICKHOUSE", "db", "8123", 8123));
+ }
+
+ @Test
+ public void blankHostYieldsNoNamespace() {
+ assertNull(LineageRelationalIdentity.buildNamespace("POSTGRESQL", "", "5432", 5432));
+ assertNull(LineageRelationalIdentity.buildNamespace("POSTGRESQL", null, "5432", 5432));
+ }
+
+ // §3.2 — fully qualified name is database.schema.table when all segments are present.
+ @Test
+ public void datasetNameJoinsAllThreeSegments() {
+ assertEquals(
+ "analytics.staging.orders",
+ LineageRelationalIdentity.datasetName(
+ new RelationalTable("analytics", "staging", "orders")));
+ }
+
+ // §3.2 — databases without a catalog level use schema.table.
+ @Test
+ public void datasetNameOmitsBlankCatalog() {
+ assertEquals(
+ "staging.orders",
+ LineageRelationalIdentity.datasetName(new RelationalTable(null, "staging", "orders")));
+ assertEquals(
+ "staging.orders",
+ LineageRelationalIdentity.datasetName(new RelationalTable(" ", "staging", "orders")));
+ }
+
+ @Test
+ public void datasetNameOmitsBlankSchema() {
+ assertEquals(
+ "orders", LineageRelationalIdentity.datasetName(new RelationalTable(null, null, "orders")));
+ }
+
+ // §3.2 — casing is preserved verbatim (Snowflake UPPER vs Postgres lower resolve upstream).
+ @Test
+ public void datasetNamePreservesSegmentCasing() {
+ assertEquals(
+ "ANALYTICS.STAGING.ORDERS",
+ LineageRelationalIdentity.datasetName(
+ new RelationalTable("ANALYTICS", "STAGING", "ORDERS")));
+ }
+
+ @Test
+ public void datasetNameIsNullWhenTableBlank() {
+ assertNull(LineageRelationalIdentity.datasetName(null));
+ }
+
+ // §3.2 — a table recovered from SQL (schema.table, no catalog) is qualified with the connection
+ // catalog so it matches a write of catalog.schema.table for the same table.
+ @Test
+ public void withDefaultCatalogFillsBlankCatalogSoReadMatchesWrite() {
+ RelationalTable parsedRead = new RelationalTable(null, "staging", "orders");
+ String readName =
+ LineageRelationalIdentity.datasetName(
+ LineageRelationalIdentity.withDefaultCatalog(parsedRead, "analytics"));
+ String writeName =
+ LineageRelationalIdentity.datasetName(
+ new RelationalTable("analytics", "staging", "orders"));
+ assertEquals("analytics.staging.orders", readName);
+ assertEquals(writeName, readName);
+ }
+
+ @Test
+ public void withDefaultCatalogLeavesExistingCatalogUntouched() {
+ RelationalTable qualified =
+ LineageRelationalIdentity.withDefaultCatalog(
+ new RelationalTable("other", "staging", "orders"), "analytics");
+ assertEquals("other.staging.orders", LineageRelationalIdentity.datasetName(qualified));
+ }
+
+ // §3.2 — a bare table from a SELECT is filled with both the connection catalog and schema so it
+ // matches an explicitly catalog.schema-qualified write.
+ @Test
+ public void withDefaultsFillsBlankCatalogAndSchema() {
+ RelationalTable bare = new RelationalTable(null, null, "orders");
+ assertEquals(
+ "analytics.staging.orders",
+ LineageRelationalIdentity.datasetName(
+ LineageRelationalIdentity.withDefaults(bare, "analytics", "staging")));
+ }
+
+ @Test
+ public void withDefaultsLeavesPresentSegmentsUntouched() {
+ RelationalTable qualified =
+ LineageRelationalIdentity.withDefaults(
+ new RelationalTable(null, "marts", "orders"), "analytics", "staging");
+ // schema present ("marts") is kept; only the blank catalog is filled.
+ assertEquals("analytics.marts.orders", LineageRelationalIdentity.datasetName(qualified));
+ }
+
+ @Test
+ public void withDefaultCatalogNoOpWhenCatalogBlank() {
+ RelationalTable table = new RelationalTable(null, "staging", "orders");
+ assertEquals("staging.orders", LineageRelationalIdentity.datasetName(table));
+ assertEquals(
+ "staging.orders",
+ LineageRelationalIdentity.datasetName(
+ LineageRelationalIdentity.withDefaultCatalog(table, " ")));
+ }
+}
diff --git a/engine/src/test/java/org/apache/hop/lineage/LineageRelationalIoEmitterTest.java b/engine/src/test/java/org/apache/hop/lineage/LineageRelationalIoEmitterTest.java
new file mode 100644
index 0000000000..4bbf4cae16
--- /dev/null
+++ b/engine/src/test/java/org/apache/hop/lineage/LineageRelationalIoEmitterTest.java
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.row.IRowMeta;
+import org.apache.hop.core.row.RowMeta;
+import org.apache.hop.core.row.value.ValueMetaInteger;
+import org.apache.hop.core.row.value.ValueMetaString;
+import org.apache.hop.lineage.context.LineageSubjectType;
+import org.apache.hop.lineage.hub.LineageHub;
+import org.apache.hop.lineage.model.LineageEvent;
+import org.apache.hop.lineage.model.LineageEventKind;
+import org.apache.hop.lineage.model.RelationalIoLineagePayload;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.apache.hop.lineage.model.RelationalTable;
+import org.apache.hop.lineage.model.RelationalWriteColumn;
+import org.apache.hop.pipeline.PipelineMeta;
+import org.apache.hop.pipeline.engine.IPipelineEngine;
+import org.apache.hop.pipeline.transform.ITransform;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+@ExtendWith(MockitoExtension.class)
+class LineageRelationalIoEmitterTest {
+
+ /**
+ * A Table Output-style write: known target table, resolved relational namespace, column schema.
+ */
+ @Test
+ void emitTransformRelationalWrite_postsRelationalEventWithContractIdentity() {
+ LineageHub hub = mock(LineageHub.class);
+ ITransform tr = transform("tr-log-w", "Table output", "TableOutput");
+ DatabaseMeta db = postgres("db", "5432");
+
+ IRowMeta rowMeta = new RowMeta();
+ rowMeta.addValueMeta(new ValueMetaInteger("id"));
+ rowMeta.addValueMeta(new ValueMetaString("name"));
+
+ try (MockedStatic<LineageHub> staticHub = Mockito.mockStatic(LineageHub.class)) {
+ staticHub.when(LineageHub::getInstance).thenReturn(hub);
+
+ LineageRelationalIoEmitter.emitTransformRelationalWrite(
+ tr, db, "analytics", "staging", "orders", rowMeta, true, null);
+ }
+
+ verify(hub)
+ .emit(
+ argThat(
+ (LineageEvent e) -> {
+ if (e.getKind() != LineageEventKind.RELATIONAL_IO) {
+ return false;
+ }
+ if (e.getContext().getSubjectType() != LineageSubjectType.TRANSFORM) {
+ return false;
+ }
+ if (!(e.getPayload() instanceof RelationalIoLineagePayload p)) {
+ return false;
+ }
+ if (p.getOperation() != RelationalIoOperation.WRITE
+ || !"postgres://db:5432".equals(p.getDatasetNamespace())
+ || p.getInputs().size() != 0
+ || p.getOutputs().size() != 1) {
+ return false;
+ }
+ RelationalTable out = p.getOutputs().get(0);
+ boolean tableOk =
+ "analytics".equals(out.getDatabase())
+ && "staging".equals(out.getSchema())
+ && "orders".equals(out.getTable());
+ boolean schemaOk =
+ p.getOutputSchema() != null
+ && p.getOutputSchema().getColumns().size() == 2
+ && "id".equals(p.getOutputSchema().getColumns().get(0).getName());
+ return tableOk && schemaOk && p.getSqlText() == null && p.isSuccess();
+ }));
+ }
+
+ /** A Table Input-style read: SQL retained for downstream parsing, inputs deferred (empty). */
+ @Test
+ void emitTransformRelationalRead_carriesSqlAndDefersInputParsing() {
+ LineageHub hub = mock(LineageHub.class);
+ ITransform tr = transform("tr-log-r", "Table input", "TableInput");
+ DatabaseMeta db = postgres("db", "5432");
+
+ IRowMeta rowMeta = new RowMeta();
+ rowMeta.addValueMeta(new ValueMetaInteger("id"));
+
+ String sql = "SELECT id FROM analytics.staging.orders";
+
+ try (MockedStatic<LineageHub> staticHub = Mockito.mockStatic(LineageHub.class)) {
+ staticHub.when(LineageHub::getInstance).thenReturn(hub);
+
+ LineageRelationalIoEmitter.emitTransformRelationalRead(
+ tr, db, sql, null, rowMeta, true, null);
+ }
+
+ verify(hub)
+ .emit(
+ argThat(
+ (LineageEvent e) -> {
+ if (!(e.getPayload() instanceof RelationalIoLineagePayload p)) {
+ return false;
+ }
+ return p.getOperation() == RelationalIoOperation.READ
+ && sql.equals(p.getSqlText())
+ && p.getInputs().isEmpty()
+ && p.getOutputs().isEmpty()
+ && p.getOutputSchema() != null
+ && p.getOutputSchema().getColumns().size() == 1
+ && "postgres://db:5432".equals(p.getDatasetNamespace());
+ }));
+ }
+
+ /** Blank port falls back to the database default port, per contract §3.1. */
+ @Test
+ void emitTransformRelationalWrite_blankPortUsesDefault() {
+ LineageHub hub = mock(LineageHub.class);
+ ITransform tr = transform("tr-log-dp", "Table output", "TableOutput");
+ DatabaseMeta db = postgres("db", "");
+
+ try (MockedStatic<LineageHub> staticHub = Mockito.mockStatic(LineageHub.class)) {
+ staticHub.when(LineageHub::getInstance).thenReturn(hub);
+
+ LineageRelationalIoEmitter.emitTransformRelationalWrite(
+ tr, db, "analytics", "staging", "orders", null, true, null);
+ }
+
+ verify(hub)
+ .emit(
+ argThat(
+ (LineageEvent e) ->
+ e.getPayload() instanceof RelationalIoLineagePayload p
+ && "postgres://db:5432".equals(p.getDatasetNamespace())
+ && p.getOutputSchema() == null));
+ }
+
+ /** No connection means no identity to key on — the emitter is a silent no-op. */
+ @Test
+ void emitTransformRelationalWrite_nullDatabaseMeta_doesNotEmit() {
+ LineageHub hub = mock(LineageHub.class);
+ ITransform tr = mock(ITransform.class);
+
+ try (MockedStatic<LineageHub> staticHub = Mockito.mockStatic(LineageHub.class)) {
+ staticHub.when(LineageHub::getInstance).thenReturn(hub);
+
+ LineageRelationalIoEmitter.emitTransformRelationalWrite(
+ tr, null, "analytics", "staging", "orders", null, true, null);
+ }
+
+ verifyNoInteractions(hub);
+ }
+
+ private static ITransform transform(String logId, String name, String pluginId) {
+ ITransform tr = mock(ITransform.class);
+ ILogChannel logCh = mock(ILogChannel.class);
+ when(logCh.getLogChannelId()).thenReturn(logId);
+ when(tr.getLogChannel()).thenReturn(logCh);
+ when(tr.getTransformName()).thenReturn(name);
+ when(tr.getCopy()).thenReturn(0);
+ when(tr.getTransformPluginId()).thenReturn(pluginId);
+ when(tr.resolve(anyString())).thenAnswer(inv -> inv.getArgument(0));
+
+ PipelineMeta pm = new PipelineMeta();
+ pm.setName("pipe1");
+ pm.setFilename("/tmp/pipe1.hpl");
+ @SuppressWarnings("unchecked")
+ IPipelineEngine<PipelineMeta> pipeline = mock(IPipelineEngine.class);
+ when(pipeline.getPipelineMeta()).thenReturn(pm);
+ when(pipeline.getFilename()).thenReturn("/tmp/pipe1.hpl");
+ when(pipeline.getLogChannelId()).thenReturn("pipe-log-1");
+ when(tr.getPipeline()).thenReturn(pipeline);
+ return tr;
+ }
+
+ private static DatabaseMeta postgres(String host, String port) {
+ DatabaseMeta db = mock(DatabaseMeta.class);
+ when(db.getPluginId()).thenReturn("POSTGRESQL");
+ when(db.getHostname()).thenReturn(host);
+ when(db.getPort()).thenReturn(port);
+ when(db.getDefaultDatabasePort()).thenReturn(5432);
+ return db;
+ }
+
+ @Test
+ void writeColumn_mapsStreamFieldToTargetColumnAndResolvesOrigin() {
+ RowMeta rowMeta = new RowMeta();
+ ValueMetaString amount = new ValueMetaString("amount");
+ amount.setOrigin("Read orders_source");
+ rowMeta.addValueMeta(amount);
+
+ RelationalWriteColumn column =
+ LineageRelationalIoEmitter.writeColumn(rowMeta, "amount_col", "amount");
+ assertEquals("amount_col", column.getTargetColumn());
+ assertEquals("amount", column.getStreamField());
+ assertEquals("Read orders_source", column.getOriginTransform());
+ }
+
+ @Test
+ void writeColumn_fallsBackToStreamNameWhenTargetBlankAndSkipsWhenUnresolvable() {
+ RowMeta rowMeta = new RowMeta();
+ rowMeta.addValueMeta(new ValueMetaString("id")); // no origin set
+
+ RelationalWriteColumn column = LineageRelationalIoEmitter.writeColumn(rowMeta, "", "id");
+ assertEquals("id", column.getTargetColumn());
+ assertEquals("id", column.getStreamField());
+ assertNull(column.getOriginTransform());
+
+ // blank stream field or missing row meta -> null so the caller skips the column
+ assertNull(LineageRelationalIoEmitter.writeColumn(rowMeta, "id", ""));
+ assertNull(LineageRelationalIoEmitter.writeColumn(null, "id", "id"));
+ }
+
+ @Test
+ void writeColumnsFromRow_mapsEveryFieldOneToOne() {
+ RowMeta rowMeta = new RowMeta();
+ ValueMetaString id = new ValueMetaString("id");
+ id.setOrigin("Read orders_source");
+ ValueMetaString amount = new ValueMetaString("amount");
+ amount.setOrigin("Read orders_source");
+ rowMeta.addValueMeta(id);
+ rowMeta.addValueMeta(amount);
+
+ List<RelationalWriteColumn> columns = LineageRelationalIoEmitter.writeColumnsFromRow(rowMeta);
+ assertEquals(2, columns.size());
+ assertEquals("id", columns.get(0).getTargetColumn());
+ assertEquals("id", columns.get(0).getStreamField());
+ assertEquals("Read orders_source", columns.get(0).getOriginTransform());
+ assertTrue(LineageRelationalIoEmitter.writeColumnsFromRow(null).isEmpty());
+ }
+
+ /**
+ * A delete reports the affected table but must not publish the transform's input row shape as the
+ * target's column schema — the transform reads those columns, the table does not gain them.
+ */
+ @Test
+ void emitTransformRelationalDelete_reportsTableWithoutColumnSchema() {
+ LineageHub hub = mock(LineageHub.class);
+ ITransform tr = transform("tr-log-d", "Delete", "Delete");
+ DatabaseMeta db = postgres("db", "5432");
+
+ try (MockedStatic<LineageHub> staticHub = Mockito.mockStatic(LineageHub.class)) {
+ staticHub.when(LineageHub::getInstance).thenReturn(hub);
+
+ LineageRelationalIoEmitter.emitTransformRelationalDelete(
+ tr, db, "analytics", "staging", "orders", true, null);
+ }
+
+ verify(hub)
+ .emit(
+ argThat(
+ (LineageEvent e) -> {
+ if (!(e.getPayload() instanceof RelationalIoLineagePayload p)) {
+ return false;
+ }
+ return p.getOperation() == RelationalIoOperation.DELETE
+ && p.getOutputs().size() == 1
+ && "orders".equals(p.getOutputs().get(0).getTable())
+ && p.getOutputSchema() == null
+ && p.getWriteColumns().isEmpty();
+ }));
+ }
+
+ /**
+ * The guard the ~15 transform call sites rely on: anything thrown while building the event is
+ * absorbed here, so a transform that calls the emitter bare still completes.
+ */
+ @Test
+ void emit_neverPropagatesAFailureToTheTransform() {
+ ITransform tr = transform("tr-log-x", "Table output", "TableOutput");
+ DatabaseMeta db = postgres("db", "5432");
+ // A connection that blows up the moment the emitter asks it for the catalog.
+ when(db.getDatabaseName()).thenThrow(new IllegalStateException("connection meta exploded"));
+
+ assertDoesNotThrow(
+ () ->
+ LineageRelationalIoEmitter.emitTransformRelationalWrite(
+ tr, db, "analytics", "staging", "orders", null, true, null));
+ }
+
+ /** A connection that cannot be resolved yields null rather than failing the transform. */
+ @Test
+ void lineageConnection_returnsNullInsteadOfThrowing() {
+ ITransform tr = mock(ITransform.class);
+ when(tr.getLogChannel()).thenReturn(mock(ILogChannel.class));
+ PipelineMeta meta = mock(PipelineMeta.class);
+ when(meta.findDatabase(anyString(), Mockito.any()))
+ .thenThrow(new IllegalStateException("no such connection"));
+
+ assertNull(LineageRelationalIoEmitter.lineageConnection(tr, meta, "missing"));
+ }
+
+ /** Missing arguments short-circuit before any lookup is attempted. */
+ @Test
+ void lineageConnection_isANoOpForMissingArguments() {
+ ITransform tr = mock(ITransform.class);
+ assertNull(LineageRelationalIoEmitter.lineageConnection(tr, mock(PipelineMeta.class), ""));
+ assertNull(LineageRelationalIoEmitter.lineageConnection(tr, null, "any"));
+ assertNull(LineageRelationalIoEmitter.lineageConnection(null, mock(PipelineMeta.class), "any"));
+ }
+}
diff --git a/integration-tests/openlineage/0001-openlineage-generate.hpl b/integration-tests/openlineage/0001-openlineage-generate.hpl
new file mode 100644
index 0000000000..22e6d76c6d
--- /dev/null
+++ b/integration-tests/openlineage/0001-openlineage-generate.hpl
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0001-openlineage-generate</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Emits lineage: when run with the lineage hub enabled and the openlineage sink selected, this pipeline produces START/COMPLETE run events for the Marquez job "0001-openlineage-generate" in the "hop" namespace.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/06/29 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/06/29 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Generate rows</from>
+ <to>Write to log</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Generate rows</name>
+ <type>RowGenerator</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <name>marker</name>
+ <type>String</type>
+ <nullif>openlineage-it</nullif>
+ <length>-1</length>
+ <precision>-1</precision>
+ <set_empty_string>N</set_empty_string>
+ </field>
+ </fields>
+ <interval_in_ms>5000</interval_in_ms>
+ <last_time_field>FiveSecondsAgo</last_time_field>
+ <never_ending>N</never_ending>
+ <limit>1</limit>
+ <row_time_field>now</row_time_field>
+ <attributes/>
+ <GUI>
+ <xloc>112</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Write to log</name>
+ <type>WriteToLog</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <loglevel>log_level_basic</loglevel>
+ <displayHeader>Y</displayHeader>
+ <limitRows>N</limitRows>
+ <limitRowsNumber>0</limitRowsNumber>
+ <logmessage>openlineage integration test marker</logmessage>
+ <fields>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>304</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0002-openlineage-validate.hpl b/integration-tests/openlineage/0002-openlineage-validate.hpl
new file mode 100644
index 0000000000..5417d63d60
--- /dev/null
+++ b/integration-tests/openlineage/0002-openlineage-validate.hpl
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0002-openlineage-validate</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Validates that lineage reached Marquez: GET /api/v1/namespaces/hop returns HTTP 200 only after the openlineage sink has delivered at least one event in the "hop" namespace. Any other status aborts the pipeline with an error, failing the test.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/06/29 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/06/29 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Generate rows</from>
+ <to>Query Marquez namespace</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Query Marquez namespace</from>
+ <to>check status 200</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>check status 200</from>
+ <to>Abort</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Generate rows</name>
+ <type>RowGenerator</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+</fields>
+ <interval_in_ms>5000</interval_in_ms>
+ <last_time_field>FiveSecondsAgo</last_time_field>
+ <never_ending>N</never_ending>
+ <limit>1</limit>
+ <row_time_field>now</row_time_field>
+ <attributes/>
+ <GUI>
+ <xloc>112</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Query Marquez namespace</name>
+ <type>Rest</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <applicationType>JSON</applicationType>
+ <method>GET</method>
+ <url>${MARQUEZ_API}/api/v1/namespaces/${OPENLINEAGE_NAMESPACE}</url>
+ <urlInField>N</urlInField>
+ <dynamicMethod>N</dynamicMethod>
+ <methodFieldName/>
+ <urlField/>
+ <bodyField/>
+ <httpLogin/>
+ <httpPassword>Encrypted </httpPassword>
+ <proxyHost/>
+ <proxyPort/>
+ <preemptive>N</preemptive>
+ <trustStoreFile/>
+ <trustStorePassword>Encrypted </trustStorePassword>
+ <headers>
+ </headers>
+ <parameters>
+ </parameters>
+ <matrixParameters>
+ </matrixParameters>
+ <result>
+ <name>result</name>
+ <code>result_status</code>
+ <response_time/>
+ <response_header/>
+ </result>
+ <attributes/>
+ <GUI>
+ <xloc>272</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>check status 200</name>
+ <type>FilterRows</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <send_true_to>Abort</send_true_to>
+ <send_false_to/>
+ <compare>
+ <condition>
+ <negated>Y</negated>
+ <leftvalue>result_status</leftvalue>
+ <function>=</function>
+ <rightvalue/>
+ <value>
+ <name>constant</name>
+ <type>Integer</type>
+ <text>200</text>
+ <length>-1</length>
+ <precision>-1</precision>
+ <isnull>N</isnull>
+ <mask>####0;-####0</mask>
+ </value>
+ </condition>
+ </compare>
+ <attributes/>
+ <GUI>
+ <xloc>464</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Abort</name>
+ <type>Abort</type>
+ <description>Aborts with an error when Marquez did not return HTTP 200 for the "hop" namespace, i.e. no lineage was delivered.</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <abort_option>ABORT_WITH_ERROR</abort_option>
+ <always_log_rows>Y</always_log_rows>
+ <row_threshold>0</row_threshold>
+ <attributes/>
+ <GUI>
+ <xloc>656</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0003-openlineage-warehouse.hpl b/integration-tests/openlineage/0003-openlineage-warehouse.hpl
new file mode 100644
index 0000000000..9b83dade17
--- /dev/null
+++ b/integration-tests/openlineage/0003-openlineage-warehouse.hpl
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0003-openlineage-warehouse</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Reads public.orders_source and writes public.orders_target on the "warehouse" Postgres connection. The Table Input read and Table Output write each emit a WAREHOUSE_IO lineage event, which the OpenLineage sink delivers to Marquez as datasets in the postgres://postgres:5432 namespace.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/07/05 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/07/05 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Read orders_source</from>
+ <to>Write orders_target</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Read orders_source</name>
+ <type>TableInput</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <sql>SELECT id, amount FROM public.orders_source</sql>
+ <limit>0</limit>
+ <lookup/>
+ <execute_each_row>N</execute_each_row>
+ <variables_active>N</variables_active>
+ <attributes/>
+ <GUI>
+ <xloc>144</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Write orders_target</name>
+ <type>TableOutput</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <commit>1000</commit>
+ <connection>warehouse</connection>
+ <fields>
+ <field>
+ <column_name>id</column_name>
+ <stream_name>id</stream_name>
+ </field>
+ <field>
+ <column_name>amount</column_name>
+ <stream_name>amount</stream_name>
+ </field>
+ </fields>
+ <return_field/>
+ <ignore_errors>N</ignore_errors>
+ <only_when_have_rows>N</only_when_have_rows>
+ <partitioning_daily>N</partitioning_daily>
+ <partitioning_enabled>N</partitioning_enabled>
+ <partitioning_field/>
+ <partitioning_monthly>Y</partitioning_monthly>
+ <return_keys>N</return_keys>
+ <schema>public</schema>
+ <specify_fields>Y</specify_fields>
+ <table>orders_target</table>
+ <tablename_field/>
+ <tablename_in_field>N</tablename_in_field>
+ <tablename_in_table>Y</tablename_in_table>
+ <truncate>Y</truncate>
+ <use_batch>Y</use_batch>
+ <attributes/>
+ <GUI>
+ <xloc>352</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0004-openlineage-warehouse-validate.hpl b/integration-tests/openlineage/0004-openlineage-warehouse-validate.hpl
new file mode 100644
index 0000000000..a6bd50bf9b
--- /dev/null
+++ b/integration-tests/openlineage/0004-openlineage-warehouse-validate.hpl
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0004-openlineage-warehouse-validate</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Validates that warehouse lineage reached Marquez: GET /api/v1/namespaces returns a body that contains the warehouse dataset namespace (postgres://postgres:5432), which Marquez only creates after the sink delivered a WAREHOUSE_IO event for a table on that connection. If the namespace is absent the pipeline aborts with an error, failing the test.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/07/05 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/07/05 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Generate rows</from>
+ <to>Query Marquez namespaces</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Query Marquez namespaces</from>
+ <to>check warehouse namespace present</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>check warehouse namespace present</from>
+ <to>success</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>check warehouse namespace present</from>
+ <to>Abort</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Generate rows</name>
+ <type>RowGenerator</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+</fields>
+ <interval_in_ms>5000</interval_in_ms>
+ <last_time_field>FiveSecondsAgo</last_time_field>
+ <never_ending>N</never_ending>
+ <limit>1</limit>
+ <row_time_field>now</row_time_field>
+ <attributes/>
+ <GUI>
+ <xloc>112</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Query Marquez namespaces</name>
+ <type>Rest</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <applicationType>JSON</applicationType>
+ <method>GET</method>
+ <url>${MARQUEZ_API}/api/v1/namespaces</url>
+ <urlInField>N</urlInField>
+ <dynamicMethod>N</dynamicMethod>
+ <methodFieldName/>
+ <urlField/>
+ <bodyField/>
+ <httpLogin/>
+ <httpPassword>Encrypted </httpPassword>
+ <proxyHost/>
+ <proxyPort/>
+ <preemptive>N</preemptive>
+ <trustStoreFile/>
+ <trustStorePassword>Encrypted </trustStorePassword>
+ <headers>
+ </headers>
+ <parameters>
+ </parameters>
+ <matrixParameters>
+ </matrixParameters>
+ <result>
+ <name>namespaces_body</name>
+ <code>result_status</code>
+ <response_time/>
+ <response_header/>
+ </result>
+ <attributes/>
+ <GUI>
+ <xloc>272</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>check warehouse namespace present</name>
+ <type>FilterRows</type>
+ <description>Sends the row to Abort when the Marquez namespaces body does NOT contain the warehouse dataset namespace.</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <send_true_to>Abort</send_true_to>
+ <send_false_to>success</send_false_to>
+ <compare>
+ <condition>
+ <negated>Y</negated>
+ <leftvalue>namespaces_body</leftvalue>
+ <function>CONTAINS</function>
+ <rightvalue/>
+ <value>
+ <name>constant</name>
+ <type>String</type>
+ <text>postgres://postgres:5432</text>
+ <length>-1</length>
+ <precision>-1</precision>
+ <isnull>N</isnull>
+ <mask/>
+ </value>
+ </condition>
+ </compare>
+ <attributes/>
+ <GUI>
+ <xloc>464</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>success</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <attributes/>
+ <GUI>
+ <xloc>656</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Abort</name>
+ <type>Abort</type>
+ <description>Aborts with an error when the warehouse dataset namespace is not present in Marquez, i.e. no WAREHOUSE_IO lineage was delivered.</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <abort_option>ABORT_WITH_ERROR</abort_option>
+ <always_log_rows>Y</always_log_rows>
+ <row_threshold>0</row_threshold>
+ <attributes/>
+ <GUI>
+ <xloc>656</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0005-openlineage-warehouse-execsql.hpl b/integration-tests/openlineage/0005-openlineage-warehouse-execsql.hpl
new file mode 100644
index 0000000000..98093fe693
--- /dev/null
+++ b/integration-tests/openlineage/0005-openlineage-warehouse-execsql.hpl
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0005-openlineage-warehouse-execsql</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Runs an INSERT ... SELECT via Execute SQL on the warehouse connection. This emits a WAREHOUSE_IO EXEC event carrying the SQL, which the OpenLineage sink parses into an input table (orders_source), an output table (orders_daily) and column-level lineage (orders_daily.id/amount derive from orders_source.id/amount), delivered to Marquez as a columnLineage facet on the output dataset.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/07/19 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/07/19 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ </order>
+ <transform>
+ <name>Insert daily from source</name>
+ <type>ExecSql</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <execute_each_row>N</execute_each_row>
+ <single_statement>N</single_statement>
+ <replace_variables>N</replace_variables>
+ <quoteString>N</quoteString>
+ <sql>CREATE TABLE IF NOT EXISTS public.orders_daily (id INTEGER, amount NUMERIC(10,2));
+INSERT INTO public.orders_daily SELECT id, amount FROM public.orders_source;</sql>
+ <set_params>N</set_params>
+ <insert_field>inserted</insert_field>
+ <update_field>updated</update_field>
+ <delete_field>deleted</delete_field>
+ <read_field>read</read_field>
+ <arguments>
+ </arguments>
+ <attributes/>
+ <GUI>
+ <xloc>160</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0007-openlineage-insertupdate.hpl b/integration-tests/openlineage/0007-openlineage-insertupdate.hpl
new file mode 100644
index 0000000000..6d83fcc5d3
--- /dev/null
+++ b/integration-tests/openlineage/0007-openlineage-insertupdate.hpl
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0007-openlineage-insertupdate</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Reads public.orders_source and upserts into public.orders_upsert with an Insert/Update transform. The write emits per-column provenance, so the OpenLineage sink attaches a columnLineage facet (id<-id, amount<-amount) to the orders_upsert dataset in Marquez.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/08/02 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/08/02 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Read orders_source</from>
+ <to>Upsert orders_upsert</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Read orders_source</name>
+ <type>TableInput</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <sql>SELECT id, amount FROM public.orders_source</sql>
+ <limit>0</limit>
+ <lookup/>
+ <execute_each_row>N</execute_each_row>
+ <variables_active>N</variables_active>
+ <attributes/>
+ <GUI>
+ <xloc>144</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Upsert orders_upsert</name>
+ <type>InsertUpdate</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <commit>1000</commit>
+ <update_bypassed>N</update_bypassed>
+ <lookup>
+ <schema>public</schema>
+ <table>orders_upsert</table>
+ <key>
+ <name>id</name>
+ <field>id</field>
+ <condition>=</condition>
+ <name2/>
+ </key>
+ <value>
+ <name>id</name>
+ <rename>id</rename>
+ <update>N</update>
+ </value>
+ <value>
+ <name>amount</name>
+ <rename>amount</rename>
+ <update>Y</update>
+ </value>
+ </lookup>
+ <attributes/>
+ <GUI>
+ <xloc>352</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0008-openlineage-combinationlookup.hpl b/integration-tests/openlineage/0008-openlineage-combinationlookup.hpl
new file mode 100644
index 0000000000..c7311a26ac
--- /dev/null
+++ b/integration-tests/openlineage/0008-openlineage-combinationlookup.hpl
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0008-openlineage-combinationlookup</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Reads public.orders_source and maintains the public.orders_combi junk dimension with a Combination Lookup/Update transform. The key columns carry per-column provenance (id<-id, amount<-amount); the generated technical key does not. The OpenLineage sink attaches the columnLineage facet to the orders_combi dataset in Marquez.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/08/02 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/08/02 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Read orders_source</from>
+ <to>Combi orders_combi</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Read orders_source</name>
+ <type>TableInput</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <sql>SELECT id, amount FROM public.orders_source</sql>
+ <limit>0</limit>
+ <lookup/>
+ <execute_each_row>N</execute_each_row>
+ <variables_active>N</variables_active>
+ <attributes/>
+ <GUI>
+ <xloc>144</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Combi orders_combi</name>
+ <type>CombinationLookup</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <schema>public</schema>
+ <table>orders_combi</table>
+ <connection>warehouse</connection>
+ <commit>1000</commit>
+ <cache_size>9999</cache_size>
+ <replace>N</replace>
+ <preloadCache>N</preloadCache>
+ <crc>N</crc>
+ <crcfield>hashcode</crcfield>
+ <fields>
+ <key>
+ <name>id</name>
+ <lookup>id</lookup>
+ </key>
+ <key>
+ <name>amount</name>
+ <lookup>amount</lookup>
+ </key>
+ <return>
+ <name>combi_tk</name>
+ <creation_method>tablemax</creation_method>
+ <use_autoinc>N</use_autoinc>
+ </return>
+ </fields>
+ <sequence/>
+ <last_update_field/>
+ <attributes/>
+ <GUI>
+ <xloc>352</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0009-openlineage-dimensionlookup.hpl b/integration-tests/openlineage/0009-openlineage-dimensionlookup.hpl
new file mode 100644
index 0000000000..3ea303d8a5
--- /dev/null
+++ b/integration-tests/openlineage/0009-openlineage-dimensionlookup.hpl
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0009-openlineage-dimensionlookup</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Reads public.orders_source and maintains the public.orders_dim slowly-changing dimension with a Dimension Lookup/Update transform. The natural key and the argument-bound attribute carry per-column provenance (id<-id, amount<-amount); the generated technical key, version and validity dates do not. The OpenLineage sink attaches the columnLineage facet to the orders_dim dataset in Marquez.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/08/02 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/08/02 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Read orders_source</from>
+ <to>Dimension orders_dim</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Read orders_source</name>
+ <type>TableInput</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <sql>SELECT id, amount FROM public.orders_source</sql>
+ <limit>0</limit>
+ <lookup/>
+ <execute_each_row>N</execute_each_row>
+ <variables_active>N</variables_active>
+ <attributes/>
+ <GUI>
+ <xloc>144</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Dimension orders_dim</name>
+ <type>DimensionLookup</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <cache_size>5000</cache_size>
+ <commit>1000</commit>
+ <connection>warehouse</connection>
+ <fields>
+ <date>
+ <from>date_from</from>
+ <name/>
+ <to>date_to</to>
+ </date>
+ <field>
+ <lookup>amount</lookup>
+ <name>amount</name>
+ <update>Insert</update>
+ </field>
+ <key>
+ <lookup>id</lookup>
+ <name>id</name>
+ </key>
+ <return>
+ <creation_method>tablemax</creation_method>
+ <name>dim_tk</name>
+ <rename/>
+ <version>version</version>
+ </return>
+ </fields>
+ <max_year>2199</max_year>
+ <min_year>1900</min_year>
+ <preload_cache>N</preload_cache>
+ <schema>public</schema>
+ <sequence/>
+ <start_date_field_name/>
+ <table>orders_dim</table>
+ <tkSourceField/>
+ <unknown_row_check_disabled>N</unknown_row_check_disabled>
+ <update>Y</update>
+ <useBatch>N</useBatch>
+ <use_start_date_alternative>N</use_start_date_alternative>
+ <attributes/>
+ <GUI>
+ <xloc>352</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0010-openlineage-pgbulkloader.hpl b/integration-tests/openlineage/0010-openlineage-pgbulkloader.hpl
new file mode 100644
index 0000000000..d1532405d1
--- /dev/null
+++ b/integration-tests/openlineage/0010-openlineage-pgbulkloader.hpl
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0010-openlineage-pgbulkloader</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Reads public.orders_source and bulk-loads public.orders_bulk with the PostgreSQL Bulk Loader. The loader's field mapping carries per-column provenance (id<-id, amount<-amount), so the OpenLineage sink attaches the columnLineage facet to the orders_bulk dataset in Marquez. Representative of the database bulk loaders.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/08/02 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/08/02 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Read orders_source</from>
+ <to>Bulk load orders_bulk</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Read orders_source</name>
+ <type>TableInput</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <sql>SELECT id, amount FROM public.orders_source</sql>
+ <limit>0</limit>
+ <lookup/>
+ <execute_each_row>N</execute_each_row>
+ <variables_active>N</variables_active>
+ <attributes/>
+ <GUI>
+ <xloc>144</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Bulk load orders_bulk</name>
+ <type>PGBulkLoader</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <connection>warehouse</connection>
+ <delimiter>;</delimiter>
+ <enclosure>"</enclosure>
+ <load_action>TRUNCATE</load_action>
+ <mapping>
+ <date_mask/>
+ <field_name>id</field_name>
+ <stream_name>id</stream_name>
+ </mapping>
+ <mapping>
+ <date_mask/>
+ <field_name>amount</field_name>
+ <stream_name>amount</stream_name>
+ </mapping>
+ <schema>public</schema>
+ <stop_on_error>N</stop_on_error>
+ <table>orders_bulk</table>
+ <attributes/>
+ <GUI>
+ <xloc>352</xloc>
+ <yloc>80</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/0011-openlineage-dataset-columnlineage-validate.hpl b/integration-tests/openlineage/0011-openlineage-dataset-columnlineage-validate.hpl
new file mode 100644
index 0000000000..39ae7f0849
--- /dev/null
+++ b/integration-tests/openlineage/0011-openlineage-dataset-columnlineage-validate.hpl
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0011-openlineage-dataset-columnlineage-validate</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Parameterized: GET a specific warehouse dataset (${TARGET_DATASET}) from Marquez and confirm its body contains a columnLineage facet. Called once per per-writer target (orders_upsert, orders_combi, orders_dim, orders_bulk) by the writers workflow. Aborts with an error if the facet is absent, failing the test.</description>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <pipeline_status>0</pipeline_status>
+ <parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <default_value/>
+ <description>Fully-qualified dataset name to check, e.g. hop_database.public.orders_upsert</description>
+ </parameter>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+ <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+ <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2026/08/02 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/08/02 12:00:00.000</modified_date>
+ <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
+ <is_key_private>N</is_key_private>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Generate rows</from>
+ <to>Query Marquez dataset</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Query Marquez dataset</from>
+ <to>check column lineage present</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>check column lineage present</from>
+ <to>success</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>check column lineage present</from>
+ <to>Abort</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Generate rows</name>
+ <type>RowGenerator</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+</fields>
+ <interval_in_ms>5000</interval_in_ms>
+ <last_time_field>FiveSecondsAgo</last_time_field>
+ <never_ending>N</never_ending>
+ <limit>1</limit>
+ <row_time_field>now</row_time_field>
+ <attributes/>
+ <GUI>
+ <xloc>112</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Query Marquez dataset</name>
+ <type>Rest</type>
+ <description>GETs the target dataset, including its facets (schema, columnLineage).</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <applicationType>JSON</applicationType>
+ <method>GET</method>
+ <url>${MARQUEZ_API}/api/v1/namespaces/${WAREHOUSE_NAMESPACE_ENCODED}/datasets/${TARGET_DATASET}</url>
+ <urlInField>N</urlInField>
+ <dynamicMethod>N</dynamicMethod>
+ <methodFieldName/>
+ <urlField/>
+ <bodyField/>
+ <httpLogin/>
+ <httpPassword>Encrypted </httpPassword>
+ <proxyHost/>
+ <proxyPort/>
+ <preemptive>N</preemptive>
+ <trustStoreFile/>
+ <trustStorePassword>Encrypted </trustStorePassword>
+ <headers>
+ </headers>
+ <parameters>
+ </parameters>
+ <matrixParameters>
+ </matrixParameters>
+ <result>
+ <name>dataset_body</name>
+ <code>result_status</code>
+ <response_time/>
+ <response_header/>
+ </result>
+ <attributes/>
+ <GUI>
+ <xloc>272</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>check column lineage present</name>
+ <type>FilterRows</type>
+ <description>Sends the row to Abort when the dataset body does NOT contain a populated columnLineage facet. Matches "inputFields" rather than "columnLineage": Marquez always emits the columnLineage key (null/empty when there is no lineage), so only inputFields proves real per-column provenance was delivered.</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <send_true_to>Abort</send_true_to>
+ <send_false_to>success</send_false_to>
+ <compare>
+ <condition>
+ <negated>Y</negated>
+ <leftvalue>dataset_body</leftvalue>
+ <function>CONTAINS</function>
+ <rightvalue/>
+ <value>
+ <name>constant</name>
+ <type>String</type>
+ <text>inputFields</text>
+ <length>-1</length>
+ <precision>-1</precision>
+ <isnull>N</isnull>
+ <mask/>
+ </value>
+ </condition>
+ </compare>
+ <attributes/>
+ <GUI>
+ <xloc>464</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>success</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <attributes/>
+ <GUI>
+ <xloc>656</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Abort</name>
+ <type>Abort</type>
+ <description>Aborts with an error when the target dataset has no columnLineage facet.</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <abort_option>ABORT_WITH_ERROR</abort_option>
+ <always_log_rows>Y</always_log_rows>
+ <row_threshold>0</row_threshold>
+ <attributes/>
+ <GUI>
+ <xloc>656</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/openlineage/dev-env-config.json b/integration-tests/openlineage/dev-env-config.json
new file mode 100644
index 0000000000..2b87a3100a
--- /dev/null
+++ b/integration-tests/openlineage/dev-env-config.json
@@ -0,0 +1,19 @@
+{
+ "variables" : [ {
+ "name" : "MARQUEZ_API",
+ "value" : "http://marquez:5000",
+ "description" : "Base URL of the Marquez OpenLineage collector (see the docker compose yml file)"
+ }, {
+ "name" : "OPENLINEAGE_NAMESPACE",
+ "value" : "hop",
+ "description" : "The OpenLineage job namespace the sink emits under"
+ }, {
+ "name" : "WAREHOUSE_NAMESPACE",
+ "value" : "postgres://postgres:5432",
+ "description" : "OpenLineage dataset namespace for the warehouse Postgres (host:port of the 'postgres' compose service); the warehouse-lineage validate pipeline asserts this namespace exists in Marquez"
+ }, {
+ "name" : "WAREHOUSE_NAMESPACE_ENCODED",
+ "value" : "postgres%3A%2F%2Fpostgres%3A5432",
+ "description" : "URL-encoded WAREHOUSE_NAMESPACE, used in the Marquez datasets REST path by the column-lineage validate pipeline (0011)"
+ } ]
+}
diff --git a/integration-tests/openlineage/hop-config.json b/integration-tests/openlineage/hop-config.json
new file mode 100644
index 0000000000..102ac981d5
--- /dev/null
+++ b/integration-tests/openlineage/hop-config.json
@@ -0,0 +1,290 @@
+{
+ "variables": [
+ {
+ "name": "HOP_LENIENT_STRING_TO_NUMBER_CONVERSION",
+ "value": "N",
+ "description": "System wide flag to allow lenient string to number conversion for backward compatibility. If this setting is set to \"Y\", an string starting with digits will be converted successfully into a number. (example: 192.168.1.1 will be converted into 192 or 192.168 or 192168 depending on the decimal and grouping symbol). The default (N) will be to throw an error if non-numeric symbols are found in the string."
+ },
+ {
+ "name": "HOP_COMPATIBILITY_DB_IGNORE_TIMEZONE",
+ "value": "N",
+ "description": "System wide flag to ignore timezone while writing date/timestamp value to the database."
+ },
+ {
+ "name": "HOP_LOG_SIZE_LIMIT",
+ "value": "0",
+ "description": "The log size limit for all pipelines and workflows that don't have the \"log size limit\" property set in their respective properties."
+ },
+ {
+ "name": "HOP_EMPTY_STRING_DIFFERS_FROM_NULL",
+ "value": "N",
+ "description": "NULL vs Empty String. If this setting is set to Y, an empty string and null are different. Otherwise they are not."
+ },
+ {
+ "name": "HOP_MAX_LOG_SIZE_IN_LINES",
+ "value": "0",
+ "description": "The maximum number of log lines that are kept internally by Hop. Set to 0 to keep all rows (default)"
+ },
+ {
+ "name": "HOP_MAX_LOG_TIMEOUT_IN_MINUTES",
+ "value": "1440",
+ "description": "The maximum age (in minutes) of a log line while being kept internally by Hop. Set to 0 to keep all rows indefinitely (default)"
+ },
+ {
+ "name": "HOP_MAX_WORKFLOW_TRACKER_SIZE",
+ "value": "5000",
+ "description": "The maximum number of workflow trackers kept in memory"
+ },
+ {
+ "name": "HOP_MAX_ACTIONS_LOGGED",
+ "value": "5000",
+ "description": "The maximum number of action results kept in memory for logging purposes."
+ },
+ {
+ "name": "HOP_MAX_LOGGING_REGISTRY_SIZE",
+ "value": "10000",
+ "description": "The maximum number of logging registry entries kept in memory for logging purposes."
+ },
+ {
+ "name": "HOP_LOG_TAB_REFRESH_DELAY",
+ "value": "1000",
+ "description": "The hop log tab refresh delay."
+ },
+ {
+ "name": "HOP_LOG_TAB_REFRESH_PERIOD",
+ "value": "1000",
+ "description": "The hop log tab refresh period."
+ },
+ {
+ "name": "HOP_PLUGIN_CLASSES",
+ "value": null,
+ "description": "A comma delimited list of classes to scan for plugin annotations"
+ },
+ {
+ "name": "HOP_PLUGIN_PACKAGES",
+ "value": null,
+ "description": "A comma delimited list of packages to scan for plugin annotations (warning: slow!!)"
+ },
+ {
+ "name": "HOP_TRANSFORM_PERFORMANCE_SNAPSHOT_LIMIT",
+ "value": "0",
+ "description": "The maximum number of transform performance snapshots to keep in memory. Set to 0 to keep all snapshots indefinitely (default)"
+ },
+ {
+ "name": "HOP_ROWSET_GET_TIMEOUT",
+ "value": "50",
+ "description": "The name of the variable that optionally contains an alternative rowset get timeout (in ms). This only makes a difference for extremely short lived pipelines."
+ },
+ {
+ "name": "HOP_ROWSET_PUT_TIMEOUT",
+ "value": "50",
+ "description": "The name of the variable that optionally contains an alternative rowset put timeout (in ms). This only makes a difference for extremely short lived pipelines."
+ },
+ {
+ "name": "HOP_CORE_TRANSFORMS_FILE",
+ "value": null,
+ "description": "The name of the project variable that will contain the alternative location of the hop-transforms.xml file. You can use this to customize the list of available internal transforms outside of the codebase."
+ },
+ {
+ "name": "HOP_CORE_WORKFLOW_ACTIONS_FILE",
+ "value": null,
+ "description": "The name of the project variable that will contain the alternative location of the hop-workflow-actions.xml file."
+ },
+ {
+ "name": "HOP_SERVER_OBJECT_TIMEOUT_MINUTES",
+ "value": "1440",
+ "description": "This project variable will set a time-out after which waiting, completed or stopped pipelines and workflows will be automatically cleaned up. The default value is 1440 (one day)."
+ },
+ {
+ "name": "HOP_PIPELINE_PAN_JVM_EXIT_CODE",
+ "value": null,
+ "description": "Set this variable to an integer that will be returned as the Pan JVM exit code."
+ },
+ {
+ "name": "HOP_DISABLE_CONSOLE_LOGGING",
+ "value": "N",
+ "description": "Set this variable to Y to disable standard Hop logging to the console. (stdout)"
+ },
+ {
+ "name": "HOP_REDIRECT_STDERR",
+ "value": "N",
+ "description": "Set this variable to Y to redirect stderr to Hop logging."
+ },
+ {
+ "name": "HOP_REDIRECT_STDOUT",
+ "value": "N",
+ "description": "Set this variable to Y to redirect stdout to Hop logging."
+ },
+ {
+ "name": "HOP_DEFAULT_NUMBER_FORMAT",
+ "value": null,
+ "description": "The name of the variable containing an alternative default number format"
+ },
+ {
+ "name": "HOP_DEFAULT_BIGNUMBER_FORMAT",
+ "value": null,
+ "description": "The name of the variable containing an alternative default bignumber format"
+ },
+ {
+ "name": "HOP_DEFAULT_INTEGER_FORMAT",
+ "value": null,
+ "description": "The name of the variable containing an alternative default integer format"
+ },
+ {
+ "name": "HOP_DEFAULT_DATE_FORMAT",
+ "value": null,
+ "description": "The name of the variable containing an alternative default date format"
+ },
+ {
+ "name": "HOP_DEFAULT_TIMESTAMP_FORMAT",
+ "value": null,
+ "description": "The name of the variable containing an alternative default timestamp format"
+ },
+ {
+ "name": "HOP_DEFAULT_SERVLET_ENCODING",
+ "value": null,
+ "description": "Defines the default encoding for servlets, leave it empty to use Java default encoding"
+ },
+ {
+ "name": "HOP_FAIL_ON_LOGGING_ERROR",
+ "value": "N",
+ "description": "Set this variable to Y when you want the workflow/pipeline fail with an error when the related logging process (e.g. to a database) fails."
+ },
+ {
+ "name": "HOP_AGGREGATION_MIN_NULL_IS_VALUED",
+ "value": "N",
+ "description": "Set this variable to Y to set the minimum to NULL if NULL is within an aggregate. Otherwise by default NULL is ignored by the MIN aggregate and MIN is set to the minimum value that is not NULL. See also the variable HOP_AGGREGATION_ALL_NULLS_ARE_ZERO."
+ },
+ {
+ "name": "HOP_AGGREGATION_ALL_NULLS_ARE_ZERO",
+ "value": "N",
+ "description": "Set this variable to Y to return 0 when all values within an aggregate are NULL. Otherwise by default a NULL is returned when all values are NULL."
+ },
+ {
+ "name": "HOP_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER",
+ "value": "N",
+ "description": "Set this variable to Y for backward compatibility for the Text File Output transform. Setting this to Ywill add no header row at all when the append option is enabled, regardless if the file is existing or not."
+ },
+ {
+ "name": "HOP_PASSWORD_ENCODER_PLUGIN",
+ "value": "Hop",
+ "description": "Specifies the password encoder plugin to use by ID (Hop is the default)."
+ },
+ {
+ "name": "HOP_SYSTEM_HOSTNAME",
+ "value": null,
+ "description": "You can use this variable to speed up hostname lookup. Hostname lookup is performed by Hop so that it is capable of logging the server on which a workflow or pipeline is executed."
+ },
+ {
+ "name": "HOP_SERVER_JETTY_ACCEPTORS",
+ "value": null,
+ "description": "A variable to configure jetty option: acceptors for Carte"
+ },
+ {
+ "name": "HOP_SERVER_JETTY_ACCEPT_QUEUE_SIZE",
+ "value": null,
+ "description": "A variable to configure jetty option: acceptQueueSize for Carte"
+ },
+ {
+ "name": "HOP_SERVER_JETTY_RES_MAX_IDLE_TIME",
+ "value": null,
+ "description": "A variable to configure jetty option: lowResourcesMaxIdleTime for Carte"
+ },
+ {
+ "name": "HOP_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL",
+ "value": "N",
+ "description": "Set this variable to Y for backward compatibility for the Merge Rows (diff) transform. Setting this to Y will use the data from the reference stream (instead of the comparison stream) in case the compared rows are identical."
+ },
+ {
+ "name": "HOP_SPLIT_FIELDS_REMOVE_ENCLOSURE",
+ "value": "false",
+ "description": "Set this variable to false to preserve enclosure symbol after splitting the string in the Split fields transform. Changing it to true will remove first and last enclosure symbol from the resulting string chunks."
+ },
+ {
+ "name": "HOP_ALLOW_EMPTY_FIELD_NAMES_AND_TYPES",
+ "value": "false",
+ "description": "Set this variable to TRUE to allow your pipeline to pass 'null' fields and/or empty types."
+ },
+ {
+ "name": "HOP_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT",
+ "value": "false",
+ "description": "Set this variable to false to preserve global log variables defined in pipeline / workflow Properties -> Log panel. Changing it to true will clear it when export pipeline / workflow."
+ },
+ {
+ "name": "HOP_FILE_OUTPUT_MAX_STREAM_COUNT",
+ "value": "1024",
+ "description": "This project variable is used by the Text File Output transform. It defines the max number of simultaneously open files within the transform. The transform will close/reopen files as necessary to insure the max is not exceeded"
+ },
+ {
+ "name": "HOP_FILE_OUTPUT_MAX_STREAM_LIFE",
+ "value": "0",
+ "description": "This project variable is used by the Text File Output transform. It defines the max number of milliseconds between flushes of files opened by the transform."
+ },
+ {
+ "name": "HOP_USE_NATIVE_FILE_DIALOG",
+ "value": "N",
+ "description": "Set this value to Y if you want to use the system file open/save dialog when browsing files"
+ },
+ {
+ "name": "HOP_AUTO_CREATE_CONFIG",
+ "value": "Y",
+ "description": "Set this value to N if you don't want to automatically create a hop configuration file (hop-config.json) when it's missing"
+ }
+ ],
+ "LocaleDefault": "en_BE",
+ "guiProperties": {
+ "FontFixedSize": "13",
+ "MaxUndo": "100",
+ "DarkMode": "Y",
+ "FontNoteSize": "13",
+ "ShowOSLook": "Y",
+ "FontFixedStyle": "0",
+ "FontNoteName": ".AppleSystemUIFont",
+ "FontFixedName": "Monospaced",
+ "FontGraphStyle": "0",
+ "FontDefaultSize": "13",
+ "GraphColorR": "255",
+ "FontGraphSize": "13",
+ "IconSize": "32",
+ "BackgroundColorB": "255",
+ "FontNoteStyle": "0",
+ "FontGraphName": ".AppleSystemUIFont",
+ "FontDefaultName": ".AppleSystemUIFont",
+ "GraphColorG": "255",
+ "UseGlobalFileBookmarks": "Y",
+ "FontDefaultStyle": "0",
+ "GraphColorB": "255",
+ "BackgroundColorR": "255",
+ "BackgroundColorG": "255",
+ "WorkflowDialogStyle": "RESIZE,MAX,MIN",
+ "LineWidth": "1",
+ "ContextDialogShowCategories": "Y"
+ },
+ "projectsConfig": {
+ "enabled": true,
+ "projectMandatory": true,
+ "environmentMandatory": true,
+ "defaultProject": "default",
+ "defaultEnvironment": null,
+ "standardParentProject": "default",
+ "standardProjectsFolder": null,
+ "projectConfigurations": [
+ {
+ "projectName": "default",
+ "projectHome": "${HOP_CONFIG_FOLDER}",
+ "configFilename": "project-config.json"
+ }
+ ],
+ "lifecycleEnvironments": [
+ {
+ "name": "dev",
+ "purpose": "Testing",
+ "projectName": "default",
+ "configurationFiles": [
+ "${PROJECT_HOME}/dev-env-config.json"
+ ]
+ }
+ ],
+ "projectLifecycles": []
+ }
+}
\ No newline at end of file
diff --git a/integration-tests/openlineage/main-0001-openlineage.hwf b/integration-tests/openlineage/main-0001-openlineage.hwf
new file mode 100644
index 0000000000..649ab57566
--- /dev/null
+++ b/integration-tests/openlineage/main-0001-openlineage.hwf
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-0001-openlineage</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Runs a pipeline with the lineage hub enabled so the openlineage sink delivers run events to Marquez, waits for asynchronous delivery and Marquez ingestion, then validates that the "hop" namespace exists in Marquez.</description>
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/06/29 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/06/29 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>50</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0001-openlineage-generate.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0001-openlineage-generate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>208</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Wait for delivery and ingestion</name>
+ <description/>
+ <type>DELAY</type>
+ <attributes/>
+ <maximumTimeout>15</maximumTimeout>
+ <scaletime>0</scaletime>
+ <parallel>N</parallel>
+ <xloc>384</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0002-openlineage-validate.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0002-openlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>560</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>0001-openlineage-generate.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>0001-openlineage-generate.hpl</from>
+ <to>Wait for delivery and ingestion</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Wait for delivery and ingestion</from>
+ <to>0002-openlineage-validate.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git a/integration-tests/openlineage/main-0002-openlineage-warehouse.hwf b/integration-tests/openlineage/main-0002-openlineage-warehouse.hwf
new file mode 100644
index 0000000000..8c6142128e
--- /dev/null
+++ b/integration-tests/openlineage/main-0002-openlineage-warehouse.hwf
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-0002-openlineage-warehouse</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Runs a pipeline that reads and writes a Postgres table with the lineage hub enabled, so the openlineage sink delivers WAREHOUSE_IO datasets to Marquez, waits for asynchronous delivery and Marquez ingestion, then validates that the warehouse dataset namespace (postgres://postgres:5432) exists in Marquez and that both targets carry a columnLineage facet: orders_target written by Table Output, and orders_daily written by Execute SQL. Each target is asserted individually - a n [...]
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/07/05 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/07/05 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>50</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0003-openlineage-warehouse.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0003-openlineage-warehouse.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>208</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0005-openlineage-warehouse-execsql.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0005-openlineage-warehouse-execsql.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>296</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Wait for delivery and ingestion</name>
+ <description/>
+ <type>DELAY</type>
+ <attributes/>
+ <maximumTimeout>15</maximumTimeout>
+ <scaletime>0</scaletime>
+ <parallel>N</parallel>
+ <xloc>384</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0004-openlineage-warehouse-validate.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0004-openlineage-warehouse-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>560</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>validate orders_target</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0011-openlineage-dataset-columnlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <stream_name/>
+ <value>hop_database.public.orders_target</value>
+ </parameter>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>736</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>validate orders_daily</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0011-openlineage-dataset-columnlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <stream_name/>
+ <value>hop_database.public.orders_daily</value>
+ </parameter>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>848</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>0003-openlineage-warehouse.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>0003-openlineage-warehouse.hpl</from>
+ <to>0005-openlineage-warehouse-execsql.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0005-openlineage-warehouse-execsql.hpl</from>
+ <to>Wait for delivery and ingestion</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Wait for delivery and ingestion</from>
+ <to>0004-openlineage-warehouse-validate.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0004-openlineage-warehouse-validate.hpl</from>
+ <to>validate orders_target</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>validate orders_target</from>
+ <to>validate orders_daily</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git a/integration-tests/openlineage/main-0003-openlineage-writers.hwf b/integration-tests/openlineage/main-0003-openlineage-writers.hwf
new file mode 100644
index 0000000000..7408ee464c
--- /dev/null
+++ b/integration-tests/openlineage/main-0003-openlineage-writers.hwf
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-0003-openlineage-writers</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Runs the relational write transforms that carry per-column provenance (Insert/Update, Combination Lookup/Update, Dimension Lookup/Update, PostgreSQL Bulk Loader) with the lineage hub enabled, so the openlineage sink delivers a WAREHOUSE_IO dataset with a columnLineage facet per target to Marquez. After waiting for asynchronous delivery and ingestion, it asserts that each target dataset (orders_upsert, orders_combi, orders_dim, orders_bulk) carries a columnLineage facet.</d [...]
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/08/02 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/08/02 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>50</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0007-openlineage-insertupdate.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0007-openlineage-insertupdate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>208</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0008-openlineage-combinationlookup.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0008-openlineage-combinationlookup.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>336</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0009-openlineage-dimensionlookup.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0009-openlineage-dimensionlookup.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>464</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0010-openlineage-pgbulkloader.hpl</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0010-openlineage-pgbulkloader.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>592</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Wait for delivery and ingestion</name>
+ <description/>
+ <type>DELAY</type>
+ <attributes/>
+ <maximumTimeout>15</maximumTimeout>
+ <scaletime>0</scaletime>
+ <parallel>N</parallel>
+ <xloc>720</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>validate orders_upsert</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0011-openlineage-dataset-columnlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <stream_name/>
+ <value>hop_database.public.orders_upsert</value>
+ </parameter>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>848</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>validate orders_combi</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0011-openlineage-dataset-columnlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <stream_name/>
+ <value>hop_database.public.orders_combi</value>
+ </parameter>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>976</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>validate orders_dim</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0011-openlineage-dataset-columnlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <stream_name/>
+ <value>hop_database.public.orders_dim</value>
+ </parameter>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>1104</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>validate orders_bulk</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0011-openlineage-dataset-columnlineage-validate.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ <parameter>
+ <name>TARGET_DATASET</name>
+ <stream_name/>
+ <value>hop_database.public.orders_bulk</value>
+ </parameter>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>1232</xloc>
+ <yloc>48</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>0007-openlineage-insertupdate.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>0007-openlineage-insertupdate.hpl</from>
+ <to>0008-openlineage-combinationlookup.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0008-openlineage-combinationlookup.hpl</from>
+ <to>0009-openlineage-dimensionlookup.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0009-openlineage-dimensionlookup.hpl</from>
+ <to>0010-openlineage-pgbulkloader.hpl</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0010-openlineage-pgbulkloader.hpl</from>
+ <to>Wait for delivery and ingestion</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Wait for delivery and ingestion</from>
+ <to>validate orders_upsert</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>validate orders_upsert</from>
+ <to>validate orders_combi</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>validate orders_combi</from>
+ <to>validate orders_dim</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>validate orders_dim</from>
+ <to>validate orders_bulk</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git a/integration-tests/openlineage/metadata/pipeline-run-configuration/local.json b/integration-tests/openlineage/metadata/pipeline-run-configuration/local.json
new file mode 100644
index 0000000000..63794efcaf
--- /dev/null
+++ b/integration-tests/openlineage/metadata/pipeline-run-configuration/local.json
@@ -0,0 +1,17 @@
+{
+ "engineRunConfiguration": {
+ "Local": {
+ "feedback_size": "50000",
+ "sample_size": "100",
+ "sample_type_in_gui": "Last",
+ "rowset_size": "10000",
+ "safe_mode": false,
+ "show_feedback": false,
+ "topo_sort": false,
+ "gather_metrics": false
+ }
+ },
+ "configurationVariables": [],
+ "name": "local",
+ "description": "Runs your pipelines locally with the standard local Hop pipeline engine"
+}
\ No newline at end of file
diff --git a/integration-tests/openlineage/metadata/rdbms/warehouse.json b/integration-tests/openlineage/metadata/rdbms/warehouse.json
new file mode 100644
index 0000000000..288d24dc03
--- /dev/null
+++ b/integration-tests/openlineage/metadata/rdbms/warehouse.json
@@ -0,0 +1,26 @@
+{
+ "rdbms": {
+ "POSTGRESQL": {
+ "databaseName": "${POSTGRES_DATABASE}",
+ "pluginId": "POSTGRESQL",
+ "accessType": 0,
+ "hostname": "${POSTGRES_HOST}",
+ "password": "${POSTGRES_PASSWORD}",
+ "port": "${POSTGRES_PORT}",
+ "pluginName": "PostgreSQL",
+ "attributes": {
+ "SUPPORTS_TIMESTAMP_DATA_TYPE": "Y",
+ "QUOTE_ALL_FIELDS": "N",
+ "SUPPORTS_BOOLEAN_DATA_TYPE": "Y",
+ "FORCE_IDENTIFIERS_TO_LOWERCASE": "N",
+ "PRESERVE_RESERVED_WORD_CASE": "Y",
+ "SQL_CONNECT": "",
+ "FORCE_IDENTIFIERS_TO_UPPERCASE": "N",
+ "PREFERRED_SCHEMA_NAME": ""
+ },
+ "manualUrl": "",
+ "username": "${POSTGRES_USER}"
+ }
+ },
+ "name": "warehouse"
+}
diff --git a/integration-tests/openlineage/metadata/workflow-run-configuration/local.json b/integration-tests/openlineage/metadata/workflow-run-configuration/local.json
new file mode 100644
index 0000000000..e37a93039a
--- /dev/null
+++ b/integration-tests/openlineage/metadata/workflow-run-configuration/local.json
@@ -0,0 +1,9 @@
+{
+ "engineRunConfiguration": {
+ "Local": {
+ "safe_mode": false
+ }
+ },
+ "name": "local",
+ "description": "Runs your workflows locally with the standard local Hop workflow engine"
+}
\ No newline at end of file
diff --git a/integration-tests/openlineage/project-config.json b/integration-tests/openlineage/project-config.json
new file mode 100644
index 0000000000..899c6c1092
--- /dev/null
+++ b/integration-tests/openlineage/project-config.json
@@ -0,0 +1,15 @@
+{
+ "metadataBaseFolder": "${PROJECT_HOME}/metadata",
+ "unitTestsBasePath": "${PROJECT_HOME}",
+ "dataSetsCsvFolder": "${PROJECT_HOME}/datasets",
+ "enforcingExecutionInHome": true,
+ "config": {
+ "variables": [
+ {
+ "name": "HOP_LICENSE_HEADER_FILE",
+ "value": "${PROJECT_HOME}/../asf-header.txt",
+ "description": "This will automatically serialize the ASF license header into pipelines and workflows in the integration test projects"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoader.java b/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoader.java
index bad21bf20c..927c097c3c 100644
--- a/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoader.java
+++ b/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoader.java
@@ -219,6 +219,7 @@ public class CrateDBBulkLoader extends BaseTransform<CrateDBBulkLoaderMeta, Crat
if (first) {
first = false;
+
if (meta.isStreamToS3Csv()) {
data.fieldnrs = new HashMap<>();
diff --git a/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderField.java b/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderField.java
index cdbe36d258..3d12a5f8e2 100644
--- a/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderField.java
+++ b/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderField.java
@@ -33,7 +33,8 @@ public class CrateDBBulkLoaderField {
@HopMetadataProperty(
key = "stream_name",
injectionKey = "STREAM_FIELDNAME",
- injectionKeyDescription = "CrateDBBulkLoader.Inject.FIELDSTREAM")
+ injectionKeyDescription = "CrateDBBulkLoader.Inject.FIELDSTREAM",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String streamField;
@HopMetadataProperty(
diff --git a/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderMeta.java b/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderMeta.java
index 8ac7be3f65..e99a6be338 100644
--- a/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderMeta.java
+++ b/plugins/databases/cratedb/src/main/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderMeta.java
@@ -39,6 +39,8 @@ import org.apache.hop.core.util.StringUtil;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -59,6 +61,7 @@ import org.apache.hop.pipeline.transform.TransformMeta;
isIncludeJdbcDrivers = true,
classLoaderGroup = "crate-db",
actionTransformTypes = {ActionTransformType.RDBMS})
+@RelationalLineage(operation = RelationalIoOperation.WRITE)
public class CrateDBBulkLoaderMeta
extends BaseTransformMeta<CrateDBBulkLoader, CrateDBBulkLoaderData>
implements IProvidesModelerMeta {
@@ -120,7 +123,8 @@ public class CrateDBBulkLoaderMeta
@HopMetadataProperty(
key = "truncate",
injectionKey = "TRUNCATE_TABLE",
- injectionKeyDescription = "CrateDBBulkLoader.Injection.TruncateTable.Field")
+ injectionKeyDescription = "CrateDBBulkLoader.Injection.TruncateTable.Field",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TRUNCATE)
private boolean truncateTable;
@HopMetadataProperty(
diff --git a/plugins/databases/cratedb/src/test/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderLineageTest.java b/plugins/databases/cratedb/src/test/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..3001f8d535
--- /dev/null
+++ b/plugins/databases/cratedb/src/test/java/org/apache/hop/pipeline/transforms/cratedbbulkloader/CrateDBBulkLoaderLineageTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.cratedbbulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/** Checks the relational lineage the CrateDB bulk loader declares on its metadata. */
+class CrateDBBulkLoaderLineageTest {
+
+ private static CrateDBBulkLoaderMeta meta(boolean truncate) {
+ CrateDBBulkLoaderMeta meta = new CrateDBBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTablename("orders");
+ meta.setTruncateTable(truncate);
+ // The constructor takes (fieldDatabase, fieldStream).
+ meta.setFields(List.of(new CrateDBBulkLoaderField("order_id", "id")));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta(false));
+
+ assertNotNull(declaration, "CrateDBBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")),
+ LineageMetadataWalker.read(meta(false)).columns());
+ }
+
+ @Test
+ void truncatingMakesTheWriteAnOverwrite() {
+ assertFalse(LineageMetadataWalker.read(meta(false)).overwrite());
+ assertTrue(LineageMetadataWalker.read(meta(true)).overwrite());
+ }
+}
diff --git a/plugins/databases/monetdb/src/main/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderMeta.java b/plugins/databases/monetdb/src/main/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderMeta.java
index 976bfc3c0c..ca0470f2a9 100644
--- a/plugins/databases/monetdb/src/main/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderMeta.java
+++ b/plugins/databases/monetdb/src/main/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderMeta.java
@@ -37,6 +37,8 @@ import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.databases.monetdb.MonetDBDatabaseMeta;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -58,6 +60,7 @@ import org.apache.hop.pipeline.transform.TransformMeta;
actionTransformTypes = {ActionTransformType.RDBMS, ActionTransformType.OUTPUT})
@Getter
@Setter
+@RelationalLineage(operation = RelationalIoOperation.WRITE)
public class MonetDbBulkLoaderMeta
extends BaseTransformMeta<MonetDbBulkLoader, MonetDbBulkLoaderData> {
private static final Class<?> PKG =
@@ -68,10 +71,16 @@ public class MonetDbBulkLoaderMeta
@Getter
@Setter
public static class MonetDbField {
- @HopMetadataProperty(key = "stream_name", injectionKey = "TARGETFIELDS")
+ @HopMetadataProperty(
+ key = "stream_name",
+ injectionKey = "TARGETFIELDS",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_COLUMN)
private String fieldTable;
- @HopMetadataProperty(key = "field_name", injectionKey = "SOURCEFIELDS")
+ @HopMetadataProperty(
+ key = "field_name",
+ injectionKey = "SOURCEFIELDS",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String fieldStream;
@HopMetadataProperty(key = "field_format_ok", injectionKey = "FIELDFORMATOK")
@@ -94,11 +103,17 @@ public class MonetDbBulkLoaderMeta
private String dbConnectionName;
/** what's the schema for the target? */
- @HopMetadataProperty(key = "schema", injectionKey = "SCHEMANAME")
+ @HopMetadataProperty(
+ key = "schema",
+ injectionKey = "SCHEMANAME",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_SCHEMA)
private String schemaName;
/** what's the table for the target? */
- @HopMetadataProperty(key = "table", injectionKey = "SCHEMANAME")
+ @HopMetadataProperty(
+ key = "table",
+ injectionKey = "SCHEMANAME",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
private String tableName;
/** Path to the log file */
@@ -134,7 +149,10 @@ public class MonetDbBulkLoaderMeta
private String encoding;
/** Truncate table? */
- @HopMetadataProperty(key = "truncate", injectionKey = "TRUNCATE")
+ @HopMetadataProperty(
+ key = "truncate",
+ injectionKey = "TRUNCATE",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TRUNCATE)
private boolean truncate = false;
/** Fully Quote SQL used in the transform? */
diff --git a/plugins/databases/monetdb/src/test/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderLineageTest.java b/plugins/databases/monetdb/src/test/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..bc6a6fe67f
--- /dev/null
+++ b/plugins/databases/monetdb/src/test/java/org/apache/hop/pipeline/transforms/monetdbbulkloader/MonetDbBulkLoaderLineageTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.monetdbbulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/** Checks the relational lineage the MonetDB bulk loader declares on its metadata. */
+class MonetDbBulkLoaderLineageTest {
+
+ private static MonetDbBulkLoaderMeta meta(boolean truncate) {
+ MonetDbBulkLoaderMeta meta = new MonetDbBulkLoaderMeta();
+ meta.setDbConnectionName("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTableName("orders");
+ meta.setTruncate(truncate);
+ meta.setFields(List.of(new MonetDbBulkLoaderMeta.MonetDbField("order_id", "id", true)));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta(false));
+
+ assertNotNull(declaration, "MonetDbBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")),
+ LineageMetadataWalker.read(meta(false)).columns());
+ }
+
+ @Test
+ void truncatingMakesTheWriteAnOverwrite() {
+ assertFalse(LineageMetadataWalker.read(meta(false)).overwrite());
+ assertTrue(LineageMetadataWalker.read(meta(true)).overwrite());
+ }
+}
diff --git a/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderMeta.java b/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderMeta.java
index bd02036dcf..b291c53bc5 100644
--- a/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderMeta.java
+++ b/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderMeta.java
@@ -37,7 +37,10 @@ import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.core.xml.XmlHandler;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IEnumHasCode;
import org.apache.hop.metadata.api.IEnumHasCodeAndDescription;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -58,19 +61,24 @@ import org.w3c.dom.Node;
classLoaderGroup = "mysql-db")
@Getter
@Setter
+@RelationalLineage(operation = RelationalIoOperation.WRITE)
public class MySqlBulkLoaderMeta extends BaseTransformMeta<MySqlBulkLoader, MySqlBulkLoaderData> {
private static final Class<?> PKG = MySqlBulkLoaderMeta.class;
- @HopMetadataProperty(key = "schema")
+ @HopMetadataProperty(
+ key = "schema",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_SCHEMA)
private String schemaName;
- @HopMetadataProperty(key = "table")
+ @HopMetadataProperty(key = "table", hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
private String tableName;
@HopMetadataProperty(key = "fifo_file_name")
private String fifoFileName;
- @HopMetadataProperty(key = "connection")
+ @HopMetadataProperty(
+ key = "connection",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
private String connection;
@HopMetadataProperty(key = "field", groupKey = "fields")
@@ -479,10 +487,14 @@ public class MySqlBulkLoaderMeta extends BaseTransformMeta<MySqlBulkLoader, MySq
@Setter
public static final class Field {
- @HopMetadataProperty(key = "stream_name")
+ @HopMetadataProperty(
+ key = "stream_name",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_COLUMN)
private String fieldTable;
- @HopMetadataProperty(key = "field_name")
+ @HopMetadataProperty(
+ key = "field_name",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String fieldStream;
@HopMetadataProperty(key = "field_format_ok", storeWithCode = true)
diff --git a/plugins/databases/mysql/src/test/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderLineageTest.java b/plugins/databases/mysql/src/test/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..3140308e2e
--- /dev/null
+++ b/plugins/databases/mysql/src/test/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderLineageTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.mysqlbulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/** Checks the relational lineage the MySQL bulk loader declares on its metadata. */
+class MySqlBulkLoaderLineageTest {
+
+ private static MySqlBulkLoaderMeta meta() {
+ MySqlBulkLoaderMeta meta = new MySqlBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTableName("orders");
+
+ MySqlBulkLoaderMeta.Field field = new MySqlBulkLoaderMeta.Field();
+ field.setFieldTable("order_id");
+ field.setFieldStream("id");
+ meta.setFields(List.of(field));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta());
+
+ assertNotNull(declaration, "MySqlBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")), LineageMetadataWalker.read(meta()).columns());
+ }
+}
diff --git a/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMappingMeta.java b/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMappingMeta.java
index 7ac021e934..7cab4ad5d8 100644
--- a/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMappingMeta.java
+++ b/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMappingMeta.java
@@ -19,19 +19,22 @@ package org.apache.hop.pipeline.transforms.orabulkloader;
import java.util.Objects;
import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.HopMetadataPropertyType;
public class OraBulkLoaderMappingMeta {
/** Field value to dateMask after lookup */
@HopMetadataProperty(
key = "stream_name",
- injectionKeyDescription = "OraBulkLoader.Injection.Mapping.StreamName")
+ injectionKeyDescription = "OraBulkLoader.Injection.Mapping.StreamName",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_COLUMN)
private String fieldTable;
/** Field name in the stream */
@HopMetadataProperty(
key = "field_name",
- injectionKeyDescription = "OraBulkLoader.Injection.Mapping.FieldName")
+ injectionKeyDescription = "OraBulkLoader.Injection.Mapping.FieldName",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String fieldStream;
/** boolean indicating if field needs to be updated */
diff --git a/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMeta.java b/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMeta.java
index 9570322622..0537b67407 100644
--- a/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMeta.java
+++ b/plugins/databases/oracle/src/main/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderMeta.java
@@ -34,6 +34,8 @@ import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -51,6 +53,9 @@ import org.apache.hop.pipeline.transform.TransformMeta;
keywords = "i18n::OraBulkLoader.Keywords",
documentationUrl = "/pipeline/transforms/orabulkloader.html",
actionTransformTypes = {ActionTransformType.RDBMS, ActionTransformType.OUTPUT})
+@RelationalLineage(
+ operation = RelationalIoOperation.WRITE,
+ overwriteWhen = {"TRUNCATE", "REPLACE"})
public class OraBulkLoaderMeta extends BaseTransformMeta<OraBulkLoader, OraBulkLoaderData> {
private static final Class<?> PKG =
OraBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
@@ -164,7 +169,8 @@ public class OraBulkLoaderMeta extends BaseTransformMeta<OraBulkLoader, OraBulkL
@HopMetadataProperty(
key = "load_action",
injectionKey = "LOAD_ACTION",
- injectionKeyDescription = "OraBulkLoader.Injection.LoadAction")
+ injectionKeyDescription = "OraBulkLoader.Injection.LoadAction",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TRUNCATE)
private String loadAction;
/** Encoding to use */
diff --git a/plugins/databases/oracle/src/test/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderLineageTest.java b/plugins/databases/oracle/src/test/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..b2a422ea71
--- /dev/null
+++ b/plugins/databases/oracle/src/test/java/org/apache/hop/pipeline/transforms/orabulkloader/OraBulkLoaderLineageTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.orabulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Checks the relational lineage the Oracle bulk loader declares on its metadata. Oracle expresses a
+ * replacing load two ways — TRUNCATE and REPLACE — and both must read as an overwrite.
+ */
+class OraBulkLoaderLineageTest {
+
+ private static OraBulkLoaderMeta meta(String loadAction) {
+ OraBulkLoaderMeta meta = new OraBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTableName("orders");
+ meta.setLoadAction(loadAction);
+ meta.setMappings(List.of(new OraBulkLoaderMappingMeta("order_id", "id", null)));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta("APPEND"));
+
+ assertNotNull(declaration, "OraBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")),
+ LineageMetadataWalker.read(meta("APPEND")).columns());
+ }
+
+ @Test
+ void bothReplacingLoadActionsAreAnOverwrite() {
+ assertFalse(LineageMetadataWalker.read(meta("APPEND")).overwrite());
+ assertTrue(LineageMetadataWalker.read(meta("TRUNCATE")).overwrite());
+ assertTrue(LineageMetadataWalker.read(meta("REPLACE")).overwrite());
+ }
+}
diff --git a/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMappingMeta.java b/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMappingMeta.java
index ab2ace0cf5..912dd93474 100644
--- a/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMappingMeta.java
+++ b/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMappingMeta.java
@@ -34,7 +34,8 @@ public class PGBulkLoaderMappingMeta {
/** Field name in the stream */
@HopMetadataProperty(
key = "field_name",
- injectionKeyDescription = "PGBulkLoader.Injection.FieldName.Label")
+ injectionKeyDescription = "PGBulkLoader.Injection.FieldName.Label",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String fieldStream;
/** boolean indicating if field needs to be updated */
diff --git a/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMeta.java b/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMeta.java
index d79ed4bb8e..f27c9c41ca 100644
--- a/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMeta.java
+++ b/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderMeta.java
@@ -35,6 +35,8 @@ import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -54,6 +56,9 @@ import org.apache.hop.pipeline.transform.TransformMeta;
classLoaderGroup = "postgres-db",
isIncludeJdbcDrivers = true,
actionTransformTypes = {ActionTransformType.RDBMS, ActionTransformType.OUTPUT})
+@RelationalLineage(
+ operation = RelationalIoOperation.WRITE,
+ overwriteWhen = {"TRUNCATE"})
public class PGBulkLoaderMeta extends BaseTransformMeta<PGBulkLoader, PGBulkLoaderData> {
private static final Class<?> PKG = PGBulkLoaderMeta.class;
@@ -89,7 +94,8 @@ public class PGBulkLoaderMeta extends BaseTransformMeta<PGBulkLoader, PGBulkLoad
/** Load action */
@HopMetadataProperty(
key = "load_action",
- injectionKeyDescription = "PGBulkLoader.Injection.LoadAction.Label")
+ injectionKeyDescription = "PGBulkLoader.Injection.LoadAction.Label",
+ hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TRUNCATE)
private String loadAction;
/** Database name override */
diff --git a/plugins/databases/postgresql/src/test/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderLineageTest.java b/plugins/databases/postgresql/src/test/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..25ddf71fd2
--- /dev/null
+++ b/plugins/databases/postgresql/src/test/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderLineageTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.pgbulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Checks the relational lineage the PostgreSQL bulk loader declares on its metadata, including the
+ * load action that makes the write replace the table's contents rather than add to them.
+ */
+class PGBulkLoaderLineageTest {
+
+ private static PGBulkLoaderMeta meta(String loadAction) {
+ PGBulkLoaderMeta meta = new PGBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTableName("orders");
+ meta.setLoadAction(loadAction);
+ meta.setMappings(List.of(new PGBulkLoaderMappingMeta("order_id", "id", null)));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta("INSERT"));
+
+ assertNotNull(declaration, "PGBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")),
+ LineageMetadataWalker.read(meta("INSERT")).columns());
+ }
+
+ @Test
+ void onlyATruncatingLoadActionIsAnOverwrite() {
+ assertFalse(LineageMetadataWalker.read(meta("INSERT")).overwrite());
+ assertTrue(LineageMetadataWalker.read(meta("TRUNCATE")).overwrite());
+ }
+}
diff --git a/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java b/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java
index aab9c6ca41..7b60a1e8ea 100644
--- a/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java
+++ b/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java
@@ -25,7 +25,10 @@ import org.apache.hop.metadata.api.HopMetadataPropertyType;
public class SnowflakeBulkLoaderField implements Cloneable {
/** The field name on the stream */
- @HopMetadataProperty(key = "stream_field", injectionGroupKey = "OUTPUT_FIELDS")
+ @HopMetadataProperty(
+ key = "stream_field",
+ injectionGroupKey = "OUTPUT_FIELDS",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String streamField;
/** The field name on the table */
diff --git a/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java b/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java
index 3c9904af9c..b91326fbfe 100644
--- a/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java
+++ b/plugins/databases/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java
@@ -39,6 +39,8 @@ import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.core.vfs.HopVfs;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -58,6 +60,7 @@ import org.apache.hop.pipeline.transform.TransformMeta;
classLoaderGroup = "snowflake",
isIncludeJdbcDrivers = true,
actionTransformTypes = {ActionTransformType.RDBMS, ActionTransformType.OUTPUT})
+@RelationalLineage(operation = RelationalIoOperation.WRITE)
public class SnowflakeBulkLoaderMeta
extends BaseTransformMeta<SnowflakeBulkLoader, SnowflakeBulkLoaderData> {
diff --git a/plugins/databases/snowflake/src/test/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderLineageTest.java b/plugins/databases/snowflake/src/test/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..7531fa4b46
--- /dev/null
+++ b/plugins/databases/snowflake/src/test/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderLineageTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.snowflake.bulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/** Checks the relational lineage the Snowflake bulk loader declares on its metadata. */
+class SnowflakeBulkLoaderLineageTest {
+
+ private static SnowflakeBulkLoaderMeta meta() {
+ SnowflakeBulkLoaderMeta meta = new SnowflakeBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setTargetSchema("staging");
+ meta.setTargetTable("orders");
+ // The constructor takes (streamField, tableField).
+ meta.setSnowflakeBulkLoaderFields(List.of(new SnowflakeBulkLoaderField("id", "order_id")));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta());
+
+ assertNotNull(declaration, "SnowflakeBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")), LineageMetadataWalker.read(meta()).columns());
+ }
+}
diff --git a/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderField.java b/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderField.java
index 32e6f38c12..66b46b4c8b 100644
--- a/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderField.java
+++ b/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderField.java
@@ -33,7 +33,8 @@ public class VerticaBulkLoaderField {
@HopMetadataProperty(
key = "stream_name",
injectionKey = "STREAM_FIELDNAME",
- injectionKeyDescription = "VerticaBulkLoader.Inject.FIELDSTREAM")
+ injectionKeyDescription = "VerticaBulkLoader.Inject.FIELDSTREAM",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String fieldStream;
@HopMetadataProperty(
diff --git a/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderMeta.java b/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderMeta.java
index 4b4db39891..0bf6535ee9 100644
--- a/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderMeta.java
+++ b/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderMeta.java
@@ -36,6 +36,8 @@ import org.apache.hop.core.util.StringUtil;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -55,6 +57,7 @@ import org.apache.hop.pipeline.transform.TransformMeta;
isIncludeJdbcDrivers = true,
classLoaderGroup = "vertica5",
actionTransformTypes = {ActionTransformType.RDBMS, ActionTransformType.OUTPUT})
+@RelationalLineage(operation = RelationalIoOperation.WRITE)
public class VerticaBulkLoaderMeta
extends BaseTransformMeta<VerticaBulkLoader, VerticaBulkLoaderData> {
private static final Class<?> PKG = VerticaBulkLoaderMeta.class;
diff --git a/plugins/databases/vertica/src/test/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderLineageTest.java b/plugins/databases/vertica/src/test/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..d281c6f5d9
--- /dev/null
+++ b/plugins/databases/vertica/src/test/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderLineageTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.vertica.bulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/** Checks the relational lineage the Vertica bulk loader declares on its metadata. */
+class VerticaBulkLoaderLineageTest {
+
+ private static VerticaBulkLoaderMeta meta() {
+ VerticaBulkLoaderMeta meta = new VerticaBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTablename("orders");
+ // The constructor takes (fieldDatabase, fieldStream).
+ meta.setFields(List.of(new VerticaBulkLoaderField("order_id", "id")));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta());
+
+ assertNotNull(declaration, "VerticaBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")), LineageMetadataWalker.read(meta()).columns());
+ }
+}
diff --git a/plugins/misc/marketplace/src/main/resources/org/apache/hop/marketplace/optional-plugins.yaml b/plugins/misc/marketplace/src/main/resources/org/apache/hop/marketplace/optional-plugins.yaml
index fceaa63889..c7b02b3240 100644
--- a/plugins/misc/marketplace/src/main/resources/org/apache/hop/marketplace/optional-plugins.yaml
+++ b/plugins/misc/marketplace/src/main/resources/org/apache/hop/marketplace/optional-plugins.yaml
@@ -158,6 +158,12 @@ plugins:
description: OpenSearch
installPath: plugins/tech/opensearch
modulePath: plugins/tech/opensearch
+ - artifactId: hop-tech-openlineage
+ name: OpenLineage
+ category: Technology
+ description: OpenLineage lineage sink — emit run, file and warehouse (column-level) lineage to Marquez or any OpenLineage endpoint.
+ installPath: plugins/tech/openlineage
+ modulePath: plugins/tech/openlineage
- artifactId: hop-tech-salesforce
name: SaleForce
category: Technology
diff --git a/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderField.java b/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderField.java
index a3559c0aa5..648be87434 100644
--- a/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderField.java
+++ b/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderField.java
@@ -33,7 +33,8 @@ public class RedshiftBulkLoaderField {
@HopMetadataProperty(
key = "stream_name",
injectionKey = "STREAM_FIELDNAME",
- injectionKeyDescription = "RedshiftBulkLoader.Inject.FIELDSTREAM")
+ injectionKeyDescription = "RedshiftBulkLoader.Inject.FIELDSTREAM",
+ hopMetadataPropertyType = HopMetadataPropertyType.STREAM_FIELD)
private String streamField;
@HopMetadataProperty(
diff --git a/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderMeta.java b/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderMeta.java
index 9b6e17b103..d443a8a2db 100644
--- a/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderMeta.java
+++ b/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderMeta.java
@@ -36,6 +36,8 @@ import org.apache.hop.core.util.StringUtil;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.lineage.api.RelationalLineage;
+import org.apache.hop.lineage.model.RelationalIoOperation;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
@@ -55,6 +57,7 @@ import org.apache.hop.pipeline.transform.TransformMeta;
isIncludeJdbcDrivers = true,
classLoaderGroup = "redshift",
actionTransformTypes = {ActionTransformType.OUTPUT, ActionTransformType.RDBMS})
+@RelationalLineage(operation = RelationalIoOperation.WRITE)
public class RedshiftBulkLoaderMeta
extends BaseTransformMeta<RedshiftBulkLoader, RedshiftBulkLoaderData> {
private static final Class<?> PKG = RedshiftBulkLoaderMeta.class;
diff --git a/plugins/tech/aws/src/test/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderLineageTest.java b/plugins/tech/aws/src/test/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderLineageTest.java
new file mode 100644
index 0000000000..cb9bdf6352
--- /dev/null
+++ b/plugins/tech/aws/src/test/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderLineageTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.redshift.bulkloader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.apache.hop.lineage.LineageMetadataWalker;
+import org.apache.hop.lineage.LineageMetadataWalker.ColumnMapping;
+import org.apache.hop.lineage.LineageMetadataWalker.Declaration;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.junit.jupiter.api.Test;
+
+/** Checks the relational lineage the Redshift bulk loader declares on its metadata. */
+class RedshiftBulkLoaderLineageTest {
+
+ private static RedshiftBulkLoaderMeta meta(boolean truncate) {
+ RedshiftBulkLoaderMeta meta = new RedshiftBulkLoaderMeta();
+ meta.setConnection("warehouse");
+ meta.setSchemaName("staging");
+ meta.setTablename("orders");
+ meta.setTruncateTable(truncate);
+ // The constructor takes (fieldDatabase, fieldStream).
+ meta.setFields(List.of(new RedshiftBulkLoaderField("order_id", "id")));
+ return meta;
+ }
+
+ @Test
+ void declaresAWriteToTheTargetTable() {
+ Declaration declaration = LineageMetadataWalker.read(meta(false));
+
+ assertNotNull(declaration, "RedshiftBulkLoader should declare relational lineage");
+ assertEquals(RelationalIoOperation.WRITE, declaration.operation());
+ assertEquals("warehouse", declaration.connectionName());
+ assertEquals("staging", declaration.schemaName());
+ assertEquals("orders", declaration.tableName());
+ assertTrue(declaration.isUsable());
+ }
+
+ @Test
+ void mapsTheStreamFieldToTheTableColumnAndNotTheOtherWayRound() {
+ assertEquals(
+ List.of(new ColumnMapping("order_id", "id")),
+ LineageMetadataWalker.read(meta(false)).columns());
+ }
+
+ @Test
+ void truncatingMakesTheWriteAnOverwrite() {
+ assertFalse(LineageMetadataWalker.read(meta(false)).overwrite());
+ assertTrue(LineageMetadataWalker.read(meta(true)).overwrite());
+ }
+}
diff --git a/plugins/tech/openlineage/README.md b/plugins/tech/openlineage/README.md
new file mode 100644
index 0000000000..72e6ca574f
--- /dev/null
+++ b/plugins/tech/openlineage/README.md
@@ -0,0 +1,222 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+# Hop OpenLineage Lineage Sink
+
+Apache Hop plugin that implements `ILineageSink` and forwards Hop lineage observations to an
+[OpenLineage](https://openlineage.io/) collector. Primary target:
+[Marquez](https://marquezproject.github.io/marquez/).
+
+Relies on the lineage hub SPI in `hop-engine` (`org.apache.hop.lineage.spi.ILineageSink`).
+
+> **User documentation** lives in the Hop user manual under *Technology → OpenLineage*, including
+> the **dataset identity** rules another lineage producer must match to stitch into Hop's graph.
+> This file covers building and hacking on the plugin itself.
+
+## Build
+
+Built as part of the standard Hop reactor. To build and test just this plugin:
+
+```bash
+./mvnw -pl plugins/tech/openlineage clean test
+```
+
+The plugin is **marketplace-optional**: it is not in the default Hop client and is installed from
+the marketplace (or from `target/hop-tech-openlineage-*.zip`) into `plugins/tech/openlineage`.
+
+```
+plugins/tech/openlineage/hop-tech-openlineage-*.jar
+plugins/tech/openlineage/lib/openlineage-java-*.jar
+plugins/tech/openlineage/lib/openlineage-sql-java-*.jar
+plugins/tech/openlineage/lib/{jackson-datatype-*,httpclient5,micrometer,...}-*.jar
+```
+
+OpenLineage JSON is built and delivered with the official
+[`io.openlineage:openlineage-java`](https://github.com/OpenLineage/OpenLineage) client (Apache 2.0),
+so the emitted events are spec-correct by construction. Jackson core/databind/annotations,
+commons-lang3 and slf4j are provided by the Hop runtime; the client's remaining runtime
+dependencies are bundled into `lib/`.
+
+`openlineage-sql-java` carries prebuilt native libraries for every supported platform, which is why
+the packaged plugin is ~24 MB. That is the main reason it ships as an optional plugin rather than
+in the default client.
+
+## Enable in Hop
+
+Set these **ENGINE-scoped** variables:
+
+| Variable | Default | Description |
+|----------|---------|-------------|
+| `HOP_LINEAGE_ENABLED` | `N` | Set to `Y` to enable the lineage hub |
+| `HOP_LINEAGE_SINK_IDS` | *(empty)* | Set to `openlineage` to load only this sink |
+| `HOP_LINEAGE_QUEUE_CAPACITY` | `10000` | In-memory event queue size |
+| `HOP_LINEAGE_BATCH_MAX` | `100` | Max events per sink batch |
+| `HOP_LINEAGE_BATCH_LINGER_MS` | `250` | Batch linger time (ms) |
+
+### Plugin variables (read in `init()`)
+
+| Variable | Default | Description |
+|----------|---------|-------------|
+| `HOP_LINEAGE_OPENLINEAGE_URL` | *(required)* | Collector URL, e.g. `http://marquez-api:5000/api/v1/lineage` |
+| `HOP_LINEAGE_OPENLINEAGE_NAMESPACE` | `hop` | OpenLineage **job** namespace. This is *not* the dataset namespace — see the dataset identity page |
+| `HOP_LINEAGE_OPENLINEAGE_PRODUCER` | apache/hop plugin URL | OpenLineage `producer` field |
+| `HOP_LINEAGE_OPENLINEAGE_API_KEY` | *(empty)* | Optional bearer token sent as `Authorization: Bearer …` |
+| `HOP_LINEAGE_OPENLINEAGE_CONNECT_TIMEOUT_MS` | `5000` | HTTP connect timeout |
+| `HOP_LINEAGE_OPENLINEAGE_READ_TIMEOUT_MS` | `30000` | HTTP read/response timeout |
+| `HOP_LINEAGE_OPENLINEAGE_BUFFER_SIZE` | `10000` | Async outbound queue capacity |
+| `HOP_LINEAGE_OPENLINEAGE_MAX_RETRIES` | `3` | Retries per event on a *transient* failure (exponential backoff) |
+| `HOP_LINEAGE_OPENLINEAGE_RETRY_BACKOFF_MS` | `500` | Initial retry backoff; doubles each attempt |
+| `HOP_LINEAGE_OPENLINEAGE_OVERFLOW_POLICY` | `DROP` | `DROP` = drop and count when the buffer is full; `BLOCK` = wait for capacity (bounded, see below) |
+| `HOP_LINEAGE_OPENLINEAGE_ENQUEUE_TIMEOUT_MS` | `5000` | Under `BLOCK`, how long to wait for capacity before dropping |
+| `HOP_LINEAGE_OPENLINEAGE_SHUTDOWN_DRAIN_MS` | `30000` | Max time to drain the queue on shutdown |
+| `HOP_LINEAGE_OPENLINEAGE_METRICS_INTERVAL_MS` | `0` | If > 0, log `sent/failed/dropped/queued` counts at this interval (`0` = off) |
+| `HOP_LINEAGE_OPENLINEAGE_TRUSTSTORE_PATH` | *(empty)* | Path to a trust/key store for HTTPS collectors with a custom CA/cert |
+| `HOP_LINEAGE_OPENLINEAGE_TRUSTSTORE_PASSWORD` | *(empty)* | Store password (used with the trust store path) |
+| `HOP_LINEAGE_OPENLINEAGE_KEYSTORE_TYPE` | `PKCS12` | Store type for the trust store (e.g. `PKCS12`, `JKS`) |
+| `HOP_LINEAGE_OPENLINEAGE_SQL_PARSE` | `Y` | Parse Table Input / Execute SQL statements to recover their source/target tables |
+| `HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING` | `N` | Name file datasets per the OpenLineage naming spec. Off by default because it re-keys existing file datasets |
+
+> **Proxy:** the client has no proxy setting; route through a forward proxy with the JVM
+> properties `-Dhttps.proxyHost`/`-Dhttps.proxyPort` (or `http.*`) instead.
+
+## Delivery model & limitations
+
+- Events are buffered in an **in-memory** queue and POSTed by a **single worker thread**. This
+ preserves run-event ordering (`START` before `COMPLETE`) — the reason delivery is not
+ parallelised — and is the throughput ceiling of the sink.
+- **Lineage never becomes a participant in the pipeline.** The engine-side emitters swallow their
+ own failures, and the outbound queue **drops by default** rather than blocking. The caller of
+ `enqueueAll` is the lineage hub's single dispatcher thread, and a finishing pipeline waits on a
+ flush marker that same thread has to process — so blocking there for an unreachable collector
+ would delay every pipeline completion, not just lineage. `BLOCK` remains available for
+ deployments that would rather lose throughput than lose lineage, and is itself bounded by
+ `…_ENQUEUE_TIMEOUT_MS`.
+- On a hard JVM crash, undelivered events in the queue are **lost** (there is no on-disk spool).
+ Normal shutdown drains the queue up to `…_SHUTDOWN_DRAIN_MS`.
+- Transient failures (connection errors, 5xx, 408, 429) are retried. A 4xx rejection is **not**
+ retried — the collector understood the request and refused it, so resending only spends the
+ backoff. Persistent failures are logged and counted.
+
+## Event mapping
+
+| Hop `LineageEventKind` | OpenLineage output |
+|------------------------|-------------------|
+| `RUN_LIFECYCLE` | `RunEvent` — `START` / `COMPLETE` / `FAIL` |
+| `FILE_IO` | `RunEvent` (`OTHER`) with physical file datasets (`dataSource.uri` + `schema` when Hop provides `FileIoContentSchema`), correlated to the **pipeline** run |
+| `RELATIONAL_IO` | `RunEvent` (`OTHER`) with relational input/output datasets keyed by the database identity (`namespace` = `postgres://host:port`, `name` = `database.schema.table`), plus `schema`, `columnLineage` and `lifecycleStateChange` facets where known, and a `SQLJobFacet` for SQL-bearing statements |
+| `TRANSFORM_SCHEMA` | Skipped (Hop internal row shapes between transforms, not physical datasets) |
+| `HTTP_IO` | Skipped (debug log only) |
+
+Run id comes from the subject `logChannelId` when present. Job name from `pipelineName` or
+`workflowName`; transform subjects use `pipelineName/transformName` so they do not collide with the
+pipeline run in Marquez.
+
+**Parent/child runs:** transform run events carry a `ParentRunFacet` pointing at their pipeline run,
+and action run events point at their workflow run, so per-transform jobs attach to the pipeline run
+in the lineage graph instead of appearing as disconnected jobs.
+
+### Which transforms produce `RELATIONAL_IO`
+
+Transforms do not emit these events themselves. A transform's metadata **declares** its table access
+via `@RelationalLineage` plus the `RDBMS_*` property annotations, and the engine derives the event
+when the transform finishes (see the *Lineage* page of the developer manual). Covered today:
+
+| Transform | Operation | Notes |
+|-----------|-----------|-------|
+| Table Output | write | `OVERWRITE` lifecycle when truncating. Per-row dynamic table names are reported by the transform itself, since no annotation can describe them |
+| Insert/Update, Update | write | Key columns + updated value columns |
+| Delete | delete | Affected table only — a delete produces no columns, so no schema facet |
+| Combination Lookup/Update | write | Key columns; the generated technical key has no stream source and is omitted |
+| Dimension Lookup/Update | write | Natural keys + attribute columns; generated columns (technical key, version, validity dates) are omitted |
+| PostgreSQL, MySQL, Oracle, Vertica, CrateDB, MonetDB, Redshift, Snowflake bulk loaders | write | Explicit field mapping; `OVERWRITE` where the loader truncates or replaces |
+| Table Input | read | Source tables recovered by parsing the `SELECT` |
+| Execute SQL | exec | Source and target tables recovered by parsing the statement |
+
+Adding a database transform to this list is a matter of annotating its metadata; there is no
+emission code to write.
+
+### Dataset identity
+
+The `(namespace, name)` rules — and the naming another producer must match — are documented in the
+user manual under *Technology → OpenLineage → Dataset identity*
+(`docs/hop-user-manual/modules/ROOT/pages/technology/openlineage/dataset-identity.adoc`). Read it
+before integrating a second lineage producer. It also records two known gaps: Snowflake/BigQuery
+namespaces, and identifier casing.
+
+### SQL parsing
+
+Table Output knows its target table directly, but **Table Input** and **Execute SQL** only provide a
+SQL statement. The engine therefore emits `RELATIONAL_IO` events carrying the raw SQL, and this sink
+recovers the tables by parsing it with the
+[OpenLineage SQL parser](https://github.com/OpenLineage/OpenLineage/tree/main/integration/sql)
+(`io.openlineage:openlineage-sql-java`, a Rust core reached over JNI). The parser handles JOINs,
+CTEs, subqueries and `INSERT … SELECT`, and the parsed `database.schema.table` is fed through the
+same `LineageRelationalIdentity.datasetName` used for writes, so a read and a write of the same
+table produce the identical dataset node.
+
+- The native libraries are **bundled per-platform inside the jar**; no separate install.
+- **Catalog qualification:** a `SELECT ... FROM schema.table` carries no catalog segment (SQL cannot
+ name it), so the sink fills it from the connection's catalog (`RELATIONAL_IO.defaultCatalog`, i.e.
+ `DatabaseMeta.getDatabaseName()`), and likewise its preferred schema.
+- Parsing is **best-effort**: an unavailable native library, a statement the parser rejects, or a
+ bare table with no schema simply yields no (or coarser) lineage — it never fails the read.
+- Toggle with `HOP_LINEAGE_OPENLINEAGE_SQL_PARSE` (default `Y`).
+
+### Column-level lineage
+
+Emitted as the OpenLineage `columnLineage` dataset facet, from two sources:
+
+1. **Parsed SQL** — `INSERT … SELECT` in Execute SQL yields per-field edges directly from the
+ parser.
+2. **The pipeline stream path** — a read registers how each of its output stream fields maps back to
+ a source table column; a write resolves each target column through the transform that produced
+ its stream field (`IValueMeta.getOrigin()`) to the matching read. This traces through
+ pass-through transforms, and is deliberately conservative: a column whose origin is not a
+ registered read (a computed field, a join with no resolvable source) yields **no** edge rather
+ than a guess.
+
+### Known gap: file column schema
+
+Marquez **Fields** on a file dataset come from the OpenLineage `schema` facet on `FILE_IO` events.
+The sink maps `FileIoLineagePayload.contentSchema` when present, but
+`org.apache.hop.pipeline.transforms.file.BaseFileInputTransform` still emits file reads with
+`contentSchema = null`, so delimited/CSV text inputs show **0 columns**. JSON/XML/YAML file
+transforms pass a content schema of their own and are unaffected. Fixing this is an engine change
+(build a `FileIoContentSchema` from `data.outputRowMeta` in `emitLineageFileRead`), not a plugin
+change.
+
+## Tests
+
+```bash
+./mvnw -pl plugins/tech/openlineage test
+```
+
+- `OpenLineageEventMapperTest` — the event → OpenLineage mapping, including the dataset identity
+ rules and column lineage
+- `OpenLineageHttpClientTest` — which delivery failures are retried and which are not
+- `OpenLineageAsyncDispatcherTest` — overflow policy (bounded `BLOCK`, counted `DROP`) and drain
+- `OpenLineageSinkTest` — the public `ILineageSink` contract (init/accept/shutdown) against a
+ WireMock collector: delivery, exact request body, async non-blocking `accept`, retry on a
+ transient `503`
+- `RelationalSqlParserTest`, `RelationalColumnLineageCorrelatorTest` — table and column recovery
+
+End-to-end coverage against a real Marquez lives in `integration-tests/openlineage` and runs with
+`docker/integration-tests/integration-tests-openlineage.yaml`.
+
+## License
+
+Apache License 2.0 (same as Apache Hop).
diff --git a/plugins/tech/openlineage/pom.xml b/plugins/tech/openlineage/pom.xml
new file mode 100644
index 0000000000..ec2f4299ac
--- /dev/null
+++ b/plugins/tech/openlineage/pom.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.hop</groupId>
+ <artifactId>hop-plugins-tech</artifactId>
+ <version>2.20.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>hop-tech-openlineage</artifactId>
+ <packaging>jar</packaging>
+ <name>Hop Plugins Technology OpenLineage</name>
+ <description>ILineageSink plugin that maps Hop lineage events to OpenLineage JSON for Marquez</description>
+
+ <properties>
+ <!--
+ openlineage-java brings its own (older) HttpClient5. Pin it to the version Hop already
+ ships so the distribution does not end up with two copies of the same library.
+ -->
+ <openlineage.httpclient5.version>5.6.1</openlineage.httpclient5.version>
+ <!--
+ Keep in step with the jackson-databind version managed in the root pom: the modules
+ bundled here (datatype-jsr310/jdk8, module-blackbird, dataformat-yaml) run against the
+ jackson-core/databind provided by the Hop runtime, so a skew between them is a runtime
+ incompatibility rather than a build failure.
+ -->
+ <openlineage.jackson.version>2.21.5</openlineage.jackson.version>
+ <openlineage.version>1.46.0</openlineage.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.fasterxml.jackson</groupId>
+ <artifactId>jackson-bom</artifactId>
+ <version>${openlineage.jackson.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents.client5</groupId>
+ <artifactId>httpclient5</artifactId>
+ <version>${openlineage.httpclient5.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- openlineage-java pulls micrometer-core transitively at runtime; declared explicitly
+ (compile) so SimpleMeterRegistry is on the compile classpath. Same artifact/version,
+ so it is bundled once. -->
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ <version>1.16.2</version>
+ </dependency>
+ <dependency>
+ <groupId>io.openlineage</groupId>
+ <artifactId>openlineage-java</artifactId>
+ <version>${openlineage.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </exclusion>
+ <!-- jackson core/databind/annotations, commons-lang3 and slf4j are provided by the
+ Hop runtime; the remaining Jackson modules and HttpClient5/micrometer are bundled. -->
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Java bindings to the OpenLineage SQL parser (Rust core + JNI). Used to extract input
+ tables (and column lineage) from Table Input / Execute SQL statements. The native
+ libraries for each platform are bundled inside this jar; commons-lang3 is provided by
+ the Hop runtime. -->
+ <dependency>
+ <groupId>io.openlineage</groupId>
+ <artifactId>openlineage-sql-java</artifactId>
+ <version>${openlineage.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- WireMock-backed sink tests (same artifact already used by the salesforce plugin). -->
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock-jre8-standalone</artifactId>
+ <version>2.35.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/plugins/tech/openlineage/src/assembly/assembly.xml b/plugins/tech/openlineage/src/assembly/assembly.xml
new file mode 100644
index 0000000000..5e6a43165c
--- /dev/null
+++ b/plugins/tech/openlineage/src/assembly/assembly.xml
@@ -0,0 +1,38 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd">
+ <id>hop-tech-openlineage</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <baseDirectory>.</baseDirectory>
+ <files>
+ <file>
+ <source>${project.basedir}/src/main/resources/version.xml</source>
+ <outputDirectory>${hop.plugin.libdir}</outputDirectory>
+ <filtered>true</filtered>
+ </file>
+ </files>
+
+ <componentDescriptors>
+ <componentDescriptor>${maven.multiModuleProjectDirectory}/assemblies/shared/hop-plugin-libs.xml</componentDescriptor>
+ </componentDescriptors>
+</assembly>
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageAsyncDispatcher.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageAsyncDispatcher.java
new file mode 100644
index 0000000000..88a24a79c5
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageAsyncDispatcher.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import io.openlineage.client.OpenLineage.RunEvent;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.hop.core.logging.ILogChannel;
+
+/**
+ * Background worker that drains OpenLineage {@link RunEvent}s and posts them via {@link
+ * OpenLineageHttpClient}, so the lineage hub dispatch thread is not blocked on HTTP.
+ */
+final class OpenLineageAsyncDispatcher implements AutoCloseable {
+
+ /** Default ceiling on how long {@link OverflowPolicy#BLOCK} waits for buffer capacity. */
+ static final long DEFAULT_ENQUEUE_TIMEOUT_MS = 5_000;
+
+ /** Behaviour when the outbound queue is full. */
+ enum OverflowPolicy {
+ /**
+ * Wait for space, up to {@link #enqueueTimeoutMs}, then drop and count. Lossless while the
+ * collector merely lags; bounded so an unreachable collector cannot stall the caller forever.
+ */
+ BLOCK,
+ /** Drop the event and count it immediately (bounded memory, lossy). This is the default. */
+ DROP
+ }
+
+ private final BlockingQueue<RunEvent> queue;
+ private final OpenLineageEmitter emitter;
+ private final OverflowPolicy overflowPolicy;
+ private final long enqueueTimeoutMs;
+ private final ILogChannel log;
+ private final AtomicLong droppedCount = new AtomicLong();
+ private final AtomicLong sentCount = new AtomicLong();
+ private final AtomicLong failedCount = new AtomicLong();
+ private final AtomicBoolean running = new AtomicBoolean(true);
+ private final Thread worker;
+ private final ScheduledExecutorService metricsScheduler;
+
+ OpenLineageAsyncDispatcher(
+ int bufferSize, OverflowPolicy overflowPolicy, OpenLineageEmitter emitter, ILogChannel log) {
+ this(bufferSize, overflowPolicy, emitter, log, 0, DEFAULT_ENQUEUE_TIMEOUT_MS);
+ }
+
+ OpenLineageAsyncDispatcher(
+ int bufferSize,
+ OverflowPolicy overflowPolicy,
+ OpenLineageEmitter emitter,
+ ILogChannel log,
+ long metricsIntervalMs) {
+ this(bufferSize, overflowPolicy, emitter, log, metricsIntervalMs, DEFAULT_ENQUEUE_TIMEOUT_MS);
+ }
+
+ OpenLineageAsyncDispatcher(
+ int bufferSize,
+ OverflowPolicy overflowPolicy,
+ OpenLineageEmitter emitter,
+ ILogChannel log,
+ long metricsIntervalMs,
+ long enqueueTimeoutMs) {
+ this.queue = new LinkedBlockingQueue<>(bufferSize);
+ this.overflowPolicy = overflowPolicy;
+ this.enqueueTimeoutMs = enqueueTimeoutMs;
+ this.emitter = emitter;
+ this.log = log;
+ this.worker = new Thread(this::runWorker, "hop-openlineage-sink");
+ this.worker.setDaemon(true);
+ this.worker.start();
+ this.metricsScheduler = startMetricsScheduler(metricsIntervalMs);
+ }
+
+ private ScheduledExecutorService startMetricsScheduler(long intervalMs) {
+ if (intervalMs <= 0) {
+ return null;
+ }
+ ScheduledExecutorService scheduler =
+ Executors.newSingleThreadScheduledExecutor(
+ r -> {
+ Thread t = new Thread(r, "hop-openlineage-sink-metrics");
+ t.setDaemon(true);
+ return t;
+ });
+ scheduler.scheduleAtFixedRate(this::logMetrics, intervalMs, intervalMs, TimeUnit.MILLISECONDS);
+ return scheduler;
+ }
+
+ private void logMetrics() {
+ log.logBasic(
+ "OpenLineage sink metrics: sent="
+ + sentCount.get()
+ + ", failed="
+ + failedCount.get()
+ + ", dropped="
+ + droppedCount.get()
+ + ", queued="
+ + queue.size());
+ }
+
+ /**
+ * Enqueues events.
+ *
+ * <p>The caller is the lineage hub's single dispatcher thread, and the hub only regains that
+ * thread — and with it the ability to process the flush marker a finishing pipeline is waiting on
+ * — once this returns. An unbounded wait here therefore does not merely delay lineage: it stalls
+ * every pipeline and workflow completion for the hub's full flush timeout. So {@link
+ * OverflowPolicy#BLOCK} waits at most {@link #enqueueTimeoutMs} for capacity and then drops
+ * (counted), and {@link OverflowPolicy#DROP} drops at once.
+ */
+ void enqueueAll(List<RunEvent> events) {
+ for (RunEvent event : events) {
+ try {
+ boolean queued =
+ overflowPolicy == OverflowPolicy.BLOCK
+ ? queue.offer(event, enqueueTimeoutMs, TimeUnit.MILLISECONDS)
+ : queue.offer(event);
+ if (!queued) {
+ countDrop();
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ droppedCount.incrementAndGet();
+ return;
+ }
+ }
+ }
+
+ /**
+ * Counts a dropped event and reports the first drop, so an operator sees that lineage is being
+ * shed rather than discovering it only in the shutdown summary.
+ */
+ private void countDrop() {
+ if (droppedCount.getAndIncrement() == 0) {
+ log.logError(
+ "OpenLineage collector is not keeping up; dropping events (buffer of "
+ + queue.size()
+ + " full). Further drops are counted and reported on shutdown.");
+ }
+ }
+
+ long getDroppedCount() {
+ return droppedCount.get();
+ }
+
+ /** Waits for the queue to drain (best effort). */
+ void awaitDrain(long timeoutMs) throws InterruptedException {
+ long deadline = System.currentTimeMillis() + timeoutMs;
+ while (!queue.isEmpty() && System.currentTimeMillis() < deadline) {
+ Thread.sleep(20);
+ }
+ }
+
+ private void runWorker() {
+ while (running.get() || !queue.isEmpty()) {
+ try {
+ RunEvent event = queue.poll(250, TimeUnit.MILLISECONDS);
+ if (event != null) {
+ if (emitter.emit(event)) {
+ sentCount.incrementAndGet();
+ } else {
+ failedCount.incrementAndGet();
+ }
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void close() {
+ running.set(false);
+ if (metricsScheduler != null) {
+ metricsScheduler.shutdownNow();
+ }
+ try {
+ worker.join(30_000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ long dropped = droppedCount.get();
+ if (dropped > 0) {
+ log.logError("OpenLineage sink dropped " + dropped + " events due to buffer overflow");
+ }
+ emitter.close();
+ }
+
+ int queueSizeForTesting() {
+ return queue.size();
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageEmitter.java
similarity index 62%
copy from engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
copy to plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageEmitter.java
index b75944821e..ff20569848 100644
--- a/engine/src/main/java/org/apache/hop/lineage/model/LineageEventKind.java
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageEmitter.java
@@ -15,14 +15,19 @@
* limitations under the License.
*/
-package org.apache.hop.lineage.model;
+package org.apache.hop.lineage.openlineage;
-/** High-level category of a lineage observation. */
-public enum LineageEventKind {
- RUN_LIFECYCLE,
- /** Transform input/output field names and Hop types (boundary schema). */
- TRANSFORM_SCHEMA,
- FILE_IO,
- /** HTTP client traffic from transforms/actions (payload: {@link HttpLineagePayload}). */
- HTTP_IO
+import io.openlineage.client.OpenLineage.RunEvent;
+
+/**
+ * Sends a single OpenLineage {@link RunEvent} to a collector. Abstracted from {@link
+ * OpenLineageHttpClient} so the async dispatcher can be tested without real HTTP.
+ */
+interface OpenLineageEmitter extends AutoCloseable {
+
+ /** Emits one event; returns {@code true} on success. Must not throw on delivery failure. */
+ boolean emit(RunEvent event);
+
+ @Override
+ void close();
}
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageEventMapper.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageEventMapper.java
new file mode 100644
index 0000000000..4e8a7e8a03
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageEventMapper.java
@@ -0,0 +1,764 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.openlineage.client.OpenLineage;
+import io.openlineage.client.OpenLineage.DatasetFacets;
+import io.openlineage.client.OpenLineage.InputDataset;
+import io.openlineage.client.OpenLineage.OutputDataset;
+import io.openlineage.client.OpenLineage.ParentRunFacet;
+import io.openlineage.client.OpenLineage.RunEvent;
+import io.openlineage.client.OpenLineage.RunEvent.EventType;
+import io.openlineage.client.OpenLineage.SchemaDatasetFacetFields;
+import io.openlineage.client.OpenLineageClientUtils;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.hop.core.util.Utils;
+import org.apache.hop.lineage.LineageFileIdentity;
+import org.apache.hop.lineage.LineageRelationalIdentity;
+import org.apache.hop.lineage.context.LineageContext;
+import org.apache.hop.lineage.context.LineageSubjectType;
+import org.apache.hop.lineage.model.FileIoContentSchema;
+import org.apache.hop.lineage.model.FileIoLineagePayload;
+import org.apache.hop.lineage.model.FileIoOperation;
+import org.apache.hop.lineage.model.FileIoTabularColumn;
+import org.apache.hop.lineage.model.LineageEvent;
+import org.apache.hop.lineage.model.LineagePayload;
+import org.apache.hop.lineage.model.RelationalIoLineagePayload;
+import org.apache.hop.lineage.model.RelationalIoOperation;
+import org.apache.hop.lineage.model.RelationalLifecycle;
+import org.apache.hop.lineage.model.RelationalTable;
+import org.apache.hop.lineage.model.RunLifecycleLineagePayload;
+import org.apache.hop.lineage.model.RunLifecyclePhase;
+
+/**
+ * Maps Hop {@link LineageEvent} instances to OpenLineage {@link RunEvent}s using the official
+ * {@code openlineage-java} client models, so the emitted JSON is spec-correct by construction.
+ *
+ * <p>The {@code (namespace, name)} and {@code runId} identities produced here are the locked
+ * contract in the "OpenLineage dataset identity" page of the user manual — they must not change
+ * without a contract version bump. Hop log-channel ids are already UUID strings ({@code
+ * LoggingRegistry#registerLoggingSource} uses {@code UUID.randomUUID()}), so {@code runId =
+ * logChannelId} stays byte-identical once typed as a {@link UUID}; only synthetic fallbacks are
+ * derived deterministically.
+ */
+public final class OpenLineageEventMapper {
+
+ /**
+ * Hop context attributes set by {@code LineageRunLifecycleEmitter} that carry the parent run's
+ * log-channel id, used to build OpenLineage {@link ParentRunFacet}s so transform/action runs
+ * attach to their pipeline/workflow run instead of appearing as disconnected jobs.
+ */
+ static final String ATTR_PIPELINE_LOG_CHANNEL_ID = "pipelineLogChannelId";
+
+ static final String ATTR_PARENT_PIPELINE_LOG_CHANNEL_ID = "parentPipelineLogChannelId";
+ static final String ATTR_WORKFLOW_LOG_CHANNEL_ID = "workflowLogChannelId";
+
+ private final OpenLineage ol;
+ private final ObjectMapper objectMapper;
+ private final String namespace;
+ private final RelationalSqlParser sqlParser;
+ private final boolean fileSpecNaming;
+ private final RelationalColumnLineageCorrelator columnLineageCorrelator =
+ new RelationalColumnLineageCorrelator();
+
+ public OpenLineageEventMapper(String namespace, String producer) {
+ this(namespace, producer, OpenLineageClientUtils.newObjectMapper());
+ }
+
+ public OpenLineageEventMapper(String namespace, String producer, ObjectMapper objectMapper) {
+ this(namespace, producer, objectMapper, RelationalSqlParser.create(false, null));
+ }
+
+ public OpenLineageEventMapper(String namespace, String producer, RelationalSqlParser sqlParser) {
+ this(namespace, producer, OpenLineageClientUtils.newObjectMapper(), sqlParser);
+ }
+
+ public OpenLineageEventMapper(
+ String namespace, String producer, RelationalSqlParser sqlParser, boolean fileSpecNaming) {
+ this(namespace, producer, OpenLineageClientUtils.newObjectMapper(), sqlParser, fileSpecNaming);
+ }
+
+ public OpenLineageEventMapper(
+ String namespace, String producer, ObjectMapper objectMapper, RelationalSqlParser sqlParser) {
+ this(namespace, producer, objectMapper, sqlParser, false);
+ }
+
+ public OpenLineageEventMapper(
+ String namespace,
+ String producer,
+ ObjectMapper objectMapper,
+ RelationalSqlParser sqlParser,
+ boolean fileSpecNaming) {
+ this.ol = new OpenLineage(URI.create(producer));
+ this.namespace = namespace;
+ this.objectMapper = objectMapper;
+ this.sqlParser = sqlParser;
+ this.fileSpecNaming = fileSpecNaming;
+ }
+
+ /** Maps a single Hop event to zero or one OpenLineage {@link RunEvent}s. */
+ public Optional<RunEvent> toRunEvent(LineageEvent event) {
+ if (event == null) {
+ return Optional.empty();
+ }
+ return switch (event.getKind()) {
+ case RUN_LIFECYCLE -> mapRunLifecycle(event);
+ case FILE_IO -> mapFileIo(event);
+ case RELATIONAL_IO -> mapRelationalIo(event);
+ case TRANSFORM_SCHEMA -> Optional.empty();
+ case HTTP_IO -> Optional.empty();
+ };
+ }
+
+ /** Maps a batch of Hop events to OpenLineage {@link RunEvent}s (used by the sink). */
+ public List<RunEvent> mapBatch(List<LineageEvent> events) {
+ List<RunEvent> mapped = new ArrayList<>();
+ for (LineageEvent event : events) {
+ toRunEvent(event).ifPresent(mapped::add);
+ }
+ return mapped;
+ }
+
+ /**
+ * Maps a single event to its OpenLineage JSON document (as a {@link JsonNode}). Thin wrapper over
+ * {@link #toRunEvent} retained for unit tests; production delivery uses the {@link RunEvent}
+ * objects directly via the client.
+ */
+ public Optional<JsonNode> map(LineageEvent event) {
+ return toRunEvent(event).map(this::toJsonNode);
+ }
+
+ private JsonNode toJsonNode(RunEvent event) {
+ try {
+ return objectMapper.readTree(OpenLineageClientUtils.toJson(event));
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to serialize OpenLineage event", e);
+ }
+ }
+
+ private Optional<RunEvent> mapRunLifecycle(LineageEvent event) {
+ LineagePayload payload = event.getPayload();
+ if (!(payload instanceof RunLifecycleLineagePayload lifecycle)) {
+ return Optional.empty();
+ }
+ EventType eventType = toOpenLineageRunEventType(lifecycle.getPhase());
+ if (eventType == null) {
+ return Optional.empty();
+ }
+ LineageContext ctx = event.getContext();
+ ZonedDateTime eventTime = toUtc(event.getTimestampMillis());
+
+ OpenLineage.JobBuilder jobBuilder =
+ ol.newJobBuilder().namespace(namespace).name(resolveJobName(ctx));
+ if (ctx != null
+ && ctx.getSubjectType() == LineageSubjectType.TRANSFORM
+ && !Utils.isEmpty(ctx.getTransformName())) {
+ jobBuilder.facets(
+ ol.newJobFacetsBuilder()
+ .jobType(ol.newJobTypeJobFacet("BATCH", "HOP", "TRANSFORM"))
+ .build());
+ }
+
+ RunEvent runEvent =
+ ol.newRunEventBuilder()
+ .eventType(eventType)
+ .eventTime(eventTime)
+ .run(runNode(resolveRunId(ctx, event.getEventId()), eventTime, parentFacet(ctx)))
+ .job(jobBuilder.build())
+ .build();
+ return Optional.of(runEvent);
+ }
+
+ /**
+ * Builds a {@link ParentRunFacet} pointing at the run that started this subject, when the engine
+ * provided the parent's log-channel id and a resolvable parent job name. Returns empty otherwise
+ * (a ParentRunFacet requires a job namespace + name).
+ */
+ private ParentRunFacet parentFacet(LineageContext ctx) {
+ if (ctx == null) {
+ return null;
+ }
+ String parentRunId = null;
+ String parentJobName = null;
+ switch (ctx.getSubjectType()) {
+ case TRANSFORM -> {
+ parentRunId = ctx.getAttributes().get(ATTR_PIPELINE_LOG_CHANNEL_ID);
+ parentJobName = ctx.getPipelineName();
+ }
+ case ACTION -> {
+ parentRunId = ctx.getAttributes().get(ATTR_WORKFLOW_LOG_CHANNEL_ID);
+ parentJobName = ctx.getWorkflowName();
+ }
+ case PIPELINE, WORKFLOW ->
+ // A nested pipeline/workflow knows its parent run id but not the parent's job name,
+ // so it cannot form a valid ParentRunFacet here; left for a future engine enrichment.
+ parentRunId = null;
+ default -> parentRunId = null;
+ }
+ if (Utils.isEmpty(parentRunId) || Utils.isEmpty(parentJobName)) {
+ return null;
+ }
+ return ol.newParentRunFacet(
+ ol.newParentRunFacetRun(toRunUuid(parentRunId)),
+ ol.newParentRunFacetJob(namespace, parentJobName),
+ null);
+ }
+
+ private Optional<RunEvent> mapFileIo(LineageEvent event) {
+ LineagePayload payload = event.getPayload();
+ if (!(payload instanceof FileIoLineagePayload fileIo)) {
+ return Optional.empty();
+ }
+ LineageContext ctx = event.getContext();
+
+ List<InputDataset> inputs = new ArrayList<>();
+ List<OutputDataset> outputs = new ArrayList<>();
+ addFileIoDatasets(fileIo, inputs, outputs);
+ if (inputs.isEmpty() && outputs.isEmpty()) {
+ return Optional.empty();
+ }
+
+ ZonedDateTime eventTime = toUtc(event.getTimestampMillis());
+ RunEvent runEvent =
+ ol.newRunEventBuilder()
+ .eventType(EventType.OTHER)
+ .eventTime(eventTime)
+ .run(runNode(resolveFileIoRunId(ctx, event.getEventId()), eventTime, null))
+ .job(ol.newJobBuilder().namespace(namespace).name(resolveFileIoJobName(ctx)).build())
+ .inputs(inputs.isEmpty() ? null : inputs)
+ .outputs(outputs.isEmpty() ? null : outputs)
+ .build();
+ return Optional.of(runEvent);
+ }
+
+ private void addFileIoDatasets(
+ FileIoLineagePayload fileIo, List<InputDataset> inputs, List<OutputDataset> outputs) {
+ FileIoOperation op = fileIo.getOperation();
+ String sourceUri = fileIo.getSourceUri();
+ String targetUri = fileIo.getTargetUri();
+ FileIoContentSchema schema = fileIo.getContentSchema();
+
+ switch (op) {
+ case READ -> {
+ if (!Utils.isEmpty(sourceUri)) {
+ inputs.add(inputDataset(sourceUri, schema));
+ }
+ }
+ case WRITE, DELETE -> {
+ String uri = !Utils.isEmpty(targetUri) ? targetUri : sourceUri;
+ if (!Utils.isEmpty(uri)) {
+ outputs.add(outputDataset(uri, schema, op));
+ }
+ }
+ case COPY, MOVE -> {
+ if (!Utils.isEmpty(sourceUri)) {
+ inputs.add(inputDataset(sourceUri, schema));
+ }
+ if (!Utils.isEmpty(targetUri)) {
+ outputs.add(outputDataset(targetUri, schema, op));
+ }
+ }
+ default -> {
+ // no-op
+ }
+ }
+ }
+
+ private InputDataset inputDataset(String uri, FileIoContentSchema contentSchema) {
+ LineageFileIdentity.Identity id = fileDatasetId(uri);
+ return ol.newInputDatasetBuilder()
+ .namespace(id.namespace())
+ .name(id.name())
+ .facets(fileDatasetFacets(uri, contentSchema, null))
+ .build();
+ }
+
+ private OutputDataset outputDataset(
+ String uri, FileIoContentSchema contentSchema, FileIoOperation operation) {
+ LineageFileIdentity.Identity id = fileDatasetId(uri);
+ return ol.newOutputDatasetBuilder()
+ .namespace(id.namespace())
+ .name(id.name())
+ .facets(fileDatasetFacets(uri, contentSchema, fileLifecycle(operation)))
+ .build();
+ }
+
+ /**
+ * Lifecycle state of a written file dataset. File outputs replace their target, so a write (or
+ * the target of a copy/move) is {@code OVERWRITE} and a delete is {@code DROP}. Append-mode
+ * outputs are not distinguished yet — that would need the mode carried on the event. Reads have
+ * no state.
+ */
+ private OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange fileLifecycle(
+ FileIoOperation operation) {
+ if (operation == null) {
+ return null;
+ }
+ return switch (operation) {
+ case WRITE, COPY, MOVE ->
+ OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange.OVERWRITE;
+ case DELETE -> OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange.DROP;
+ default -> null;
+ };
+ }
+
+ /**
+ * The OpenLineage {@code (namespace, name)} for a file/object-store URI. With {@code
+ * HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING} enabled this follows the OpenLineage naming spec (VFS
+ * scheme → namespace, path → name via {@link LineageFileIdentity}) so a file reconciles across
+ * transforms and engines; otherwise it keeps the legacy job-namespace + filename identity for
+ * backward compatibility.
+ */
+ private LineageFileIdentity.Identity fileDatasetId(String uri) {
+ if (fileSpecNaming) {
+ LineageFileIdentity.Identity id = LineageFileIdentity.of(uri);
+ if (id != null) {
+ return id;
+ }
+ }
+ return new LineageFileIdentity.Identity(namespace, nameFromUri(uri));
+ }
+
+ private DatasetFacets fileDatasetFacets(
+ String uri,
+ FileIoContentSchema contentSchema,
+ OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange lifecycle) {
+ OpenLineage.DatasetFacetsBuilder facets = ol.newDatasetFacetsBuilder();
+ URI parsedUri = toUriOrNull(uri);
+ if (parsedUri != null) {
+ facets.dataSource(ol.newDatasourceDatasetFacet(nameFromUri(uri), parsedUri));
+ }
+ List<SchemaDatasetFacetFields> fields = schemaFields(contentSchema);
+ if (!fields.isEmpty()) {
+ facets.schema(ol.newSchemaDatasetFacet(fields));
+ }
+ if (lifecycle != null) {
+ facets.lifecycleStateChange(ol.newLifecycleStateChangeDatasetFacet(lifecycle, null));
+ }
+ return facets.build();
+ }
+
+ private List<SchemaDatasetFacetFields> schemaFields(FileIoContentSchema contentSchema) {
+ if (contentSchema == null || contentSchema.getColumns().isEmpty()) {
+ return List.of();
+ }
+ List<SchemaDatasetFacetFields> fields = new ArrayList<>(contentSchema.getColumns().size());
+ for (FileIoTabularColumn column : contentSchema.getColumns()) {
+ OpenLineage.SchemaDatasetFacetFieldsBuilder field =
+ ol.newSchemaDatasetFacetFieldsBuilder().name(column.getName());
+ if (!Utils.isEmpty(column.getHopTypeName())) {
+ field.type(column.getHopTypeName());
+ }
+ fields.add(field.build());
+ }
+ return fields;
+ }
+
+ /**
+ * Maps a {@code RELATIONAL_IO} event to a {@link RunEvent} whose input/output datasets carry the
+ * relational identity of the "OpenLineage dataset identity" page of the user manual: the dataset
+ * {@code namespace} is the physical database ({@code postgres://host:port}), <b>not</b> the Hop
+ * job namespace, and the dataset {@code name} is the engine-computed {@code
+ * database.schema.table}. Emitting datasets in the relational namespace is what lets a Hop write
+ * and, e.g., a dbt read of the same table land on one node in the lineage graph.
+ */
+ private Optional<RunEvent> mapRelationalIo(LineageEvent event) {
+ LineagePayload payload = event.getPayload();
+ if (!(payload instanceof RelationalIoLineagePayload relational)) {
+ return Optional.empty();
+ }
+ String datasetNamespace = relational.getDatasetNamespace();
+ if (Utils.isEmpty(datasetNamespace)) {
+ // No resolvable relational namespace (e.g. an embedded/file database): nothing to stitch on.
+ return Optional.empty();
+ }
+ LineageContext ctx = event.getContext();
+ FileIoContentSchema schema = relational.getOutputSchema();
+
+ // Prefer tables the engine already resolved (e.g. Table Output's known target); when it only
+ // handed us SQL (Table Input, Execute SQL), recover the tables — and column lineage — by
+ // parsing the statement.
+ List<RelationalTable> inTables = relational.getInputs();
+ List<RelationalTable> outTables = relational.getOutputs();
+ List<RelationalSqlParser.ColumnEdge> columnEdges = List.of();
+ if (inTables.isEmpty() && outTables.isEmpty() && !Utils.isEmpty(relational.getSqlText())) {
+ RelationalSqlParser.Tables parsed =
+ sqlParser.parse(relational.getSqlText(), sqlDialect(datasetNamespace));
+ inTables = parsed.inputs();
+ outTables = parsed.outputs();
+ columnEdges = parsed.columnLineage();
+ }
+
+ // Tables recovered from SQL may name neither catalog nor schema; fill them from the connection
+ // so a read of table/schema.table shares one identity with a write of catalog.schema.table.
+ String defaultCatalog = relational.getDefaultCatalog();
+ String defaultSchema = relational.getDefaultSchema();
+ inTables = qualify(inTables, defaultCatalog, defaultSchema);
+ outTables = qualify(outTables, defaultCatalog, defaultSchema);
+
+ // Column-level lineage for the stream path: a read records how its stream fields map to source
+ // columns; a write resolves its columns back through the transform that produced each stream
+ // field (RelationalWriteColumn.originTransform) to the matching read.
+ String runId = pipelineLogChannelId(ctx);
+ String transformName = ctx != null ? ctx.getTransformName() : null;
+ if (relational.getOperation() == RelationalIoOperation.READ && !inTables.isEmpty()) {
+ columnLineageCorrelator.registerRead(runId, transformName, columnEdges, inTables);
+ } else if (relational.getOperation() == RelationalIoOperation.WRITE
+ && !relational.getWriteColumns().isEmpty()) {
+ columnEdges = columnLineageCorrelator.correlate(runId, relational.getWriteColumns());
+ }
+
+ List<String> outNames = new ArrayList<>();
+ for (RelationalTable table : outTables) {
+ String name = LineageRelationalIdentity.datasetName(table);
+ if (!Utils.isEmpty(name)) {
+ outNames.add(name);
+ }
+ }
+ // Column lineage maps output fields to input fields, so it belongs on the single output dataset
+ // of an INSERT … SELECT. With zero or several output tables there is no unambiguous target.
+ OpenLineage.ColumnLineageDatasetFacet columnLineage =
+ outNames.size() == 1
+ ? columnLineageFacet(datasetNamespace, columnEdges, defaultCatalog, defaultSchema)
+ : null;
+ // A write recovered from SQL has no row schema of its own; declare its columns from the column
+ // lineage so collectors (e.g. Marquez) have output fields to render the column-level graph on.
+ FileIoContentSchema outputSchema =
+ schema == null && columnLineage != null ? schemaFromColumnEdges(columnEdges) : schema;
+
+ OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange lifecycle =
+ relationalLifecycle(relational.getLifecycle());
+ List<OutputDataset> outputs = new ArrayList<>();
+ for (String name : outNames) {
+ outputs.add(
+ ol.newOutputDatasetBuilder()
+ .namespace(datasetNamespace)
+ .name(name)
+ .facets(
+ relationalDatasetFacets(datasetNamespace, outputSchema, columnLineage, lifecycle))
+ .build());
+ }
+
+ // A read's output row shape describes the single source it selected from; attach it only when
+ // there is exactly one input and no outputs, to avoid mislabelling a multi-table join.
+ boolean schemaOnInput = outputs.isEmpty() && inTables.size() == 1;
+ List<InputDataset> inputs = new ArrayList<>();
+ for (RelationalTable table : inTables) {
+ String name = LineageRelationalIdentity.datasetName(table);
+ if (Utils.isEmpty(name)) {
+ continue;
+ }
+ inputs.add(
+ ol.newInputDatasetBuilder()
+ .namespace(datasetNamespace)
+ .name(name)
+ .facets(
+ relationalDatasetFacets(
+ datasetNamespace, schemaOnInput ? schema : null, null, null))
+ .build());
+ }
+
+ if (inputs.isEmpty() && outputs.isEmpty()) {
+ // Read events carry only SQL until a sink parses it into tables — nothing to emit yet.
+ return Optional.empty();
+ }
+
+ ZonedDateTime eventTime = toUtc(event.getTimestampMillis());
+ RunEvent runEvent =
+ ol.newRunEventBuilder()
+ .eventType(EventType.OTHER)
+ .eventTime(eventTime)
+ .run(runNode(resolveFileIoRunId(ctx, event.getEventId()), eventTime, null))
+ .job(relationalJob(ctx, relational.getSqlText()))
+ .inputs(inputs.isEmpty() ? null : inputs)
+ .outputs(outputs.isEmpty() ? null : outputs)
+ .build();
+ return Optional.of(runEvent);
+ }
+
+ /**
+ * Job for a relational event, correlated to the pipeline run like file I/O, with an optional
+ * {@code SQLJobFacet} carrying the statement text when the transform provided it (Table Input,
+ * Execute SQL).
+ */
+ private OpenLineage.Job relationalJob(LineageContext ctx, String sqlText) {
+ OpenLineage.JobBuilder job =
+ ol.newJobBuilder().namespace(namespace).name(resolveFileIoJobName(ctx));
+ if (!Utils.isEmpty(sqlText)) {
+ job.facets(ol.newJobFacetsBuilder().sql(ol.newSQLJobFacet(sqlText, null)).build());
+ }
+ return job.build();
+ }
+
+ /**
+ * SQL dialect for the parser, derived from the database namespace scheme ({@code
+ * postgres://db:5432} → {@code postgres}). Namespaces without a host (e.g. {@code bigquery}) are
+ * themselves the dialect; null lets the parser fall back to its default grammar.
+ */
+ static String sqlDialect(String datasetNamespace) {
+ if (Utils.isEmpty(datasetNamespace)) {
+ return null;
+ }
+ int sep = datasetNamespace.indexOf("://");
+ return sep > 0 ? datasetNamespace.substring(0, sep) : datasetNamespace;
+ }
+
+ private DatasetFacets relationalDatasetFacets(
+ String datasetNamespace,
+ FileIoContentSchema contentSchema,
+ OpenLineage.ColumnLineageDatasetFacet columnLineage,
+ OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange lifecycle) {
+ OpenLineage.DatasetFacetsBuilder facets = ol.newDatasetFacetsBuilder();
+ URI parsedUri = toUriOrNull(datasetNamespace);
+ if (parsedUri != null) {
+ facets.dataSource(ol.newDatasourceDatasetFacet(datasetNamespace, parsedUri));
+ }
+ List<SchemaDatasetFacetFields> fields = schemaFields(contentSchema);
+ if (!fields.isEmpty()) {
+ facets.schema(ol.newSchemaDatasetFacet(fields));
+ }
+ if (columnLineage != null) {
+ facets.columnLineage(columnLineage);
+ }
+ if (lifecycle != null) {
+ facets.lifecycleStateChange(ol.newLifecycleStateChangeDatasetFacet(lifecycle, null));
+ }
+ return facets.build();
+ }
+
+ /**
+ * Maps the neutral relational lifecycle to the OpenLineage lifecycle-state enum (names align).
+ */
+ private static OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange
+ relationalLifecycle(RelationalLifecycle lifecycle) {
+ if (lifecycle == null) {
+ return null;
+ }
+ return switch (lifecycle) {
+ case OVERWRITE -> OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange.OVERWRITE;
+ case TRUNCATE -> OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange.TRUNCATE;
+ case DROP -> OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange.DROP;
+ case CREATE -> OpenLineage.LifecycleStateChangeDatasetFacet.LifecycleStateChange.CREATE;
+ };
+ }
+
+ /**
+ * Builds a {@code columnLineage} facet from the parser's per-field edges: each output field maps
+ * to the input relational-table columns it derives from, referenced by the same {@code
+ * (namespace, name)} identity as the input datasets. Returns null when no edge resolves to a
+ * usable input.
+ */
+ private OpenLineage.ColumnLineageDatasetFacet columnLineageFacet(
+ String datasetNamespace,
+ List<RelationalSqlParser.ColumnEdge> edges,
+ String defaultCatalog,
+ String defaultSchema) {
+ if (edges == null || edges.isEmpty()) {
+ return null;
+ }
+ OpenLineage.ColumnLineageDatasetFacetFieldsBuilder fieldsBuilder =
+ ol.newColumnLineageDatasetFacetFieldsBuilder();
+ boolean anyField = false;
+ for (RelationalSqlParser.ColumnEdge edge : edges) {
+ List<OpenLineage.InputField> inputFields = new ArrayList<>();
+ for (RelationalSqlParser.FieldRef ref : edge.inputs()) {
+ RelationalTable table =
+ LineageRelationalIdentity.withDefaults(ref.table(), defaultCatalog, defaultSchema);
+ String name = LineageRelationalIdentity.datasetName(table);
+ if (Utils.isEmpty(name) || Utils.isEmpty(ref.field())) {
+ continue;
+ }
+ inputFields.add(ol.newInputField(datasetNamespace, name, ref.field(), null));
+ }
+ if (inputFields.isEmpty()) {
+ continue;
+ }
+ fieldsBuilder.put(
+ edge.outputField(),
+ ol.newColumnLineageDatasetFacetFieldsAdditional(inputFields, null, null));
+ anyField = true;
+ }
+ if (!anyField) {
+ return null;
+ }
+ return ol.newColumnLineageDatasetFacet(fieldsBuilder.build(), null);
+ }
+
+ /**
+ * Builds a tabular schema from the distinct output fields of the column lineage, so an
+ * SQL-recovered write (which carries no row schema) still declares its columns. Types are unknown
+ * from SQL parsing and are left unset.
+ */
+ private static FileIoContentSchema schemaFromColumnEdges(
+ List<RelationalSqlParser.ColumnEdge> edges) {
+ List<FileIoTabularColumn> columns = new ArrayList<>();
+ Set<String> seen = new LinkedHashSet<>();
+ for (RelationalSqlParser.ColumnEdge edge : edges) {
+ if (!Utils.isEmpty(edge.outputField()) && seen.add(edge.outputField())) {
+ columns.add(new FileIoTabularColumn(edge.outputField(), null, 0, 0, null, null, false));
+ }
+ }
+ return new FileIoContentSchema("jdbc", columns, List.of());
+ }
+
+ /** Returns {@code tables} with each blank catalog/schema filled from the connection defaults. */
+ private static List<RelationalTable> qualify(
+ List<RelationalTable> tables, String defaultCatalog, String defaultSchema) {
+ if ((Utils.isEmpty(defaultCatalog) && Utils.isEmpty(defaultSchema)) || tables.isEmpty()) {
+ return tables;
+ }
+ List<RelationalTable> qualified = new ArrayList<>(tables.size());
+ for (RelationalTable table : tables) {
+ qualified.add(LineageRelationalIdentity.withDefaults(table, defaultCatalog, defaultSchema));
+ }
+ return qualified;
+ }
+
+ private OpenLineage.Run runNode(String runId, ZonedDateTime eventTime, ParentRunFacet parent) {
+ OpenLineage.RunFacetsBuilder facets =
+ ol.newRunFacetsBuilder().nominalTime(ol.newNominalTimeRunFacet(eventTime, null));
+ if (parent != null) {
+ facets.parent(parent);
+ }
+ return ol.newRunBuilder().runId(toRunUuid(runId)).facets(facets.build()).build();
+ }
+
+ private static ZonedDateTime toUtc(long timestampMillis) {
+ return Instant.ofEpochMilli(timestampMillis).atZone(ZoneOffset.UTC);
+ }
+
+ /**
+ * Converts a Hop run id to the UUID OpenLineage requires. Hop log-channel ids are already UUID
+ * strings (used as-is to preserve the locked contract); only synthetic fallbacks are derived
+ * deterministically so the same string always yields the same UUID.
+ */
+ static UUID toRunUuid(String runId) {
+ try {
+ return UUID.fromString(runId);
+ } catch (IllegalArgumentException notAUuid) {
+ return UUID.nameUUIDFromBytes(("hop:" + runId).getBytes(StandardCharsets.UTF_8));
+ }
+ }
+
+ private static URI toUriOrNull(String uri) {
+ if (Utils.isEmpty(uri)) {
+ return null;
+ }
+ try {
+ return URI.create(uri);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ static EventType toOpenLineageRunEventType(RunLifecyclePhase phase) {
+ return switch (phase) {
+ case STARTED -> EventType.START;
+ case FINISHED -> EventType.COMPLETE;
+ case FAILED -> EventType.FAIL;
+ case FINISHING -> null;
+ };
+ }
+
+ static String resolveRunId(LineageContext ctx, String eventId) {
+ if (ctx != null && !Utils.isEmpty(ctx.getLogChannelId())) {
+ return ctx.getLogChannelId();
+ }
+ String jobName = resolveJobName(ctx);
+ String suffix = eventId != null && eventId.length() >= 8 ? eventId.substring(0, 8) : "unknown";
+ return jobName + "-" + suffix;
+ }
+
+ /**
+ * File I/O from a transform is correlated to the parent pipeline run when Hop provides {@link
+ * #ATTR_PIPELINE_LOG_CHANNEL_ID}, so Marquez shows inputs/outputs on the pipeline job the user
+ * opened (not a separate transform-only run).
+ */
+ static String resolveFileIoRunId(LineageContext ctx, String eventId) {
+ String pipelineRunId = pipelineLogChannelId(ctx);
+ if (!Utils.isEmpty(pipelineRunId)) {
+ return pipelineRunId;
+ }
+ return resolveRunId(ctx, eventId);
+ }
+
+ static String resolveFileIoJobName(LineageContext ctx) {
+ if (ctx != null && !Utils.isEmpty(ctx.getPipelineName())) {
+ return ctx.getPipelineName();
+ }
+ return resolveJobName(ctx);
+ }
+
+ static String pipelineLogChannelId(LineageContext ctx) {
+ if (ctx == null || ctx.getAttributes().isEmpty()) {
+ return null;
+ }
+ return ctx.getAttributes().get(ATTR_PIPELINE_LOG_CHANNEL_ID);
+ }
+
+ static String resolveJobName(LineageContext ctx) {
+ if (ctx == null) {
+ return "unknown";
+ }
+ if (ctx.getSubjectType() == LineageSubjectType.TRANSFORM
+ && !Utils.isEmpty(ctx.getTransformName())) {
+ if (!Utils.isEmpty(ctx.getPipelineName())) {
+ return ctx.getPipelineName() + "/" + ctx.getTransformName();
+ }
+ return ctx.getTransformName();
+ }
+ if (!Utils.isEmpty(ctx.getPipelineName())) {
+ return ctx.getPipelineName();
+ }
+ if (!Utils.isEmpty(ctx.getWorkflowName())) {
+ return ctx.getWorkflowName();
+ }
+ if (!Utils.isEmpty(ctx.getTransformName())) {
+ return ctx.getTransformName();
+ }
+ if (!Utils.isEmpty(ctx.getActionName())) {
+ return ctx.getActionName();
+ }
+ return "unknown";
+ }
+
+ static String nameFromUri(String uri) {
+ if (Utils.isEmpty(uri)) {
+ return "dataset";
+ }
+ int query = uri.indexOf('?');
+ String path = query >= 0 ? uri.substring(0, query) : uri;
+ int slash = path.lastIndexOf('/');
+ if (slash >= 0 && slash < path.length() - 1) {
+ return path.substring(slash + 1);
+ }
+ return path;
+ }
+}
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageHttpClient.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageHttpClient.java
new file mode 100644
index 0000000000..c6131f72d4
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageHttpClient.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import io.openlineage.client.OpenLineage.RunEvent;
+import io.openlineage.client.OpenLineageClient;
+import io.openlineage.client.OpenLineageClientException;
+import io.openlineage.client.transports.ApiKeyTokenProvider;
+import io.openlineage.client.transports.HttpConfig;
+import io.openlineage.client.transports.HttpSslContextConfig;
+import io.openlineage.client.transports.HttpTransport;
+import io.openlineage.client.transports.HttpTransportResponseException;
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hop.core.logging.ILogChannel;
+
+/**
+ * Posts OpenLineage {@link RunEvent}s to a collector via the official {@code openlineage-java}
+ * {@link OpenLineageClient}/{@link HttpTransport}, adding a bounded retry-with-backoff layer (the
+ * client transport itself does no retries).
+ */
+public final class OpenLineageHttpClient implements OpenLineageEmitter {
+
+ private final OpenLineageClient client;
+ private final URI collectorUri;
+ private final int maxRetries;
+ private final long retryBackoffMs;
+ private final ILogChannel log;
+ private final AtomicLong successCount = new AtomicLong();
+ private final AtomicLong failureCount = new AtomicLong();
+
+ public OpenLineageHttpClient(OpenLineageSinkConfig config, ILogChannel log) {
+ this.collectorUri = URI.create(config.getCollectorUrl());
+ this.maxRetries = config.getMaxRetries();
+ this.retryBackoffMs = config.getRetryBackoffMs();
+ this.log = log;
+
+ HttpConfig httpConfig = new HttpConfig();
+ // Split the full collector URL into base (scheme://authority) + endpoint (path), since
+ // HttpConfig otherwise defaults the endpoint to /api/v1/lineage.
+ httpConfig.setUrl(URI.create(collectorUri.getScheme() + "://" + collectorUri.getAuthority()));
+ String path = collectorUri.getRawPath();
+ if (!StringUtils.isBlank(path)) {
+ httpConfig.setEndpoint(path);
+ }
+ httpConfig.setTimeoutInMillis(config.getReadTimeoutMs());
+ if (!StringUtils.isBlank(config.getApiKey())) {
+ ApiKeyTokenProvider tokenProvider = new ApiKeyTokenProvider();
+ tokenProvider.setApiKey(config.getApiKey());
+ httpConfig.setAuth(tokenProvider);
+ }
+ if (!StringUtils.isBlank(config.getTrustStorePath())) {
+ HttpSslContextConfig ssl = new HttpSslContextConfig();
+ ssl.setKeyStorePath(config.getTrustStorePath());
+ ssl.setKeyStoreType(config.getKeyStoreType());
+ if (!StringUtils.isBlank(config.getTrustStorePassword())) {
+ ssl.setStorePassword(config.getTrustStorePassword());
+ }
+ httpConfig.setSslContextConfig(ssl);
+ }
+ // Each sink instance gets its own meter registry so the client's circuit-breaker gauge
+ // registration does not collide across instances ("Gauge already registered" warnings).
+ this.client =
+ OpenLineageClient.builder()
+ .transport(new HttpTransport(httpConfig))
+ .meterRegistry(new SimpleMeterRegistry())
+ .build();
+ }
+
+ /** Visible for tests: inject a pre-built client. */
+ OpenLineageHttpClient(
+ OpenLineageClient client,
+ URI collectorUri,
+ int maxRetries,
+ long retryBackoffMs,
+ ILogChannel log) {
+ this.client = client;
+ this.collectorUri = collectorUri;
+ this.maxRetries = maxRetries;
+ this.retryBackoffMs = retryBackoffMs;
+ this.log = log;
+ }
+
+ /**
+ * Emits one event, retrying <i>transient</i> failures up to {@code maxRetries} times with
+ * exponential backoff. Returns {@code true} on success.
+ */
+ @Override
+ public boolean emit(RunEvent event) {
+ int attempts = Math.max(1, maxRetries + 1);
+ OpenLineageClientException lastError = null;
+ int attempt = 0;
+ for (; attempt < attempts; attempt++) {
+ try {
+ client.emit(event);
+ successCount.incrementAndGet();
+ return true;
+ } catch (OpenLineageClientException e) {
+ lastError = e;
+ if (!isRetryable(e)) {
+ break; // the collector rejected the event itself; resending cannot change that
+ }
+ if (attempt < attempts - 1 && !backoff(attempt)) {
+ break; // interrupted while waiting to retry
+ }
+ }
+ }
+ failureCount.incrementAndGet();
+ log.logError(
+ "Failed to POST OpenLineage event to "
+ + collectorUri
+ + " after "
+ + Math.min(attempt + 1, attempts)
+ + " attempt(s)",
+ lastError);
+ return false;
+ }
+
+ /**
+ * Whether resending the event could plausibly succeed. Connection and 5xx failures are transient;
+ * a 4xx means the collector understood the request and rejected it (bad payload, bad
+ * credentials), so retrying only spends the backoff before failing identically. The two
+ * exceptions are 408 (request timeout) and 429 (too many requests), which explicitly invite a
+ * retry.
+ */
+ private static boolean isRetryable(OpenLineageClientException e) {
+ for (Throwable t = e; t != null; t = t.getCause()) {
+ if (t instanceof HttpTransportResponseException response) {
+ int status = response.getStatusCode();
+ if (status < 400 || status >= 500) {
+ return true;
+ }
+ return status == 408 || status == 429;
+ }
+ }
+ // No HTTP response at all (connect timeout, DNS, reset): worth another try.
+ return true;
+ }
+
+ /** Sleeps {@code retryBackoffMs * 2^attempt}; returns false if interrupted. */
+ private boolean backoff(int attempt) {
+ long delay = retryBackoffMs << Math.min(attempt, 16);
+ try {
+ Thread.sleep(delay);
+ return true;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+
+ public long getSuccessCount() {
+ return successCount.get();
+ }
+
+ public long getFailureCount() {
+ return failureCount.get();
+ }
+
+ @Override
+ public void close() {
+ try {
+ client.close();
+ } catch (Exception e) {
+ log.logDebug("Error closing OpenLineage client: " + e.getMessage());
+ }
+ }
+}
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageLineageSink.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageLineageSink.java
new file mode 100644
index 0000000000..685dce776a
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageLineageSink.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import io.openlineage.client.OpenLineage.RunEvent;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.logging.LogChannel;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.lineage.model.HttpLineagePayload;
+import org.apache.hop.lineage.model.LineageEvent;
+import org.apache.hop.lineage.model.LineageEventKind;
+import org.apache.hop.lineage.plugin.LineageSinkPlugin;
+import org.apache.hop.lineage.spi.ILineageSink;
+
+/**
+ * Hop lineage sink that maps neutral {@link LineageEvent} batches to OpenLineage JSON and POSTs
+ * them to an OpenLineage-compatible collector (e.g. Marquez).
+ */
+@LineageSinkPlugin(
+ id = "openlineage",
+ name = "OpenLineage",
+ description = "Maps Hop lineage events to OpenLineage JSON and POSTs to a collector")
+public class OpenLineageLineageSink implements ILineageSink {
+
+ private OpenLineageSinkConfig config;
+ private OpenLineageEventMapper mapper;
+ private OpenLineageHttpClient httpClient;
+ private OpenLineageAsyncDispatcher dispatcher;
+ private ILogChannel log;
+
+ @Override
+ public void init(IVariables variables, ILogChannel log) throws HopException {
+ this.log = log;
+ try {
+ this.config = OpenLineageSinkConfig.fromVariables(variables);
+ } catch (IllegalArgumentException e) {
+ throw new HopException(e.getMessage(), e);
+ }
+ this.mapper =
+ new OpenLineageEventMapper(
+ config.getNamespace(),
+ config.getProducer(),
+ RelationalSqlParser.create(config.isSqlParseEnabled(), log),
+ config.isFileSpecNaming());
+ this.httpClient = new OpenLineageHttpClient(config, log);
+ this.dispatcher =
+ new OpenLineageAsyncDispatcher(
+ config.getBufferSize(),
+ config.getOverflowPolicy(),
+ httpClient,
+ log,
+ config.getMetricsIntervalMs(),
+ config.getEnqueueTimeoutMs());
+ String msg =
+ "OpenLineage lineage sink initialized: url="
+ + config.getCollectorUrl()
+ + ", namespace="
+ + config.getNamespace()
+ + ", producer="
+ + config.getProducer();
+ log.logBasic(msg);
+ // LineageHub log channel is easy to miss in the GUI — mirror to GENERAL.
+ LogChannel.GENERAL.logBasic(msg);
+ }
+
+ @Override
+ public void accept(List<LineageEvent> events) throws HopException {
+ if (events == null || events.isEmpty()) {
+ return;
+ }
+ List<LineageEvent> copy = new ArrayList<>(events.size());
+ for (LineageEvent event : events) {
+ if (event.getKind() == LineageEventKind.HTTP_IO
+ && event.getPayload() instanceof HttpLineagePayload http) {
+ if (log.isDebug()) {
+ log.logDebug(
+ "Skipping HTTP_IO lineage event in v1: " + http.getMethod() + " " + http.getUrl());
+ }
+ continue;
+ }
+ if (event.getKind() == LineageEventKind.TRANSFORM_SCHEMA) {
+ if (log.isDebug()) {
+ log.logDebug(
+ "Skipping TRANSFORM_SCHEMA in v1 (Hop row metadata, not a physical dataset)");
+ }
+ continue;
+ }
+ copy.add(event);
+ }
+ if (copy.isEmpty()) {
+ return;
+ }
+ List<RunEvent> runEvents = mapper.mapBatch(copy);
+ if (!runEvents.isEmpty()) {
+ dispatcher.enqueueAll(runEvents);
+ }
+ }
+
+ @Override
+ public void shutdown() throws HopException {
+ if (dispatcher != null) {
+ long drainMs = config != null ? config.getShutdownDrainMs() : 30_000;
+ try {
+ dispatcher.awaitDrain(drainMs);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ long dropped = dispatcher.getDroppedCount();
+ dispatcher.close();
+ if (httpClient != null) {
+ log.logBasic(
+ "OpenLineage sink metrics: sent="
+ + httpClient.getSuccessCount()
+ + ", failed="
+ + httpClient.getFailureCount()
+ + ", dropped="
+ + dropped);
+ }
+ dispatcher = null;
+ }
+ httpClient = null;
+ mapper = null;
+ config = null;
+ }
+}
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageSinkConfig.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageSinkConfig.java
new file mode 100644
index 0000000000..0f3f0ed9e9
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/OpenLineageSinkConfig.java
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.lineage.openlineage.OpenLineageAsyncDispatcher.OverflowPolicy;
+
+/** Plugin configuration resolved from Hop variables in {@link OpenLineageLineageSink#init}. */
+public final class OpenLineageSinkConfig {
+
+ public static final String VAR_URL = "HOP_LINEAGE_OPENLINEAGE_URL";
+ public static final String VAR_NAMESPACE = "HOP_LINEAGE_OPENLINEAGE_NAMESPACE";
+ public static final String VAR_PRODUCER = "HOP_LINEAGE_OPENLINEAGE_PRODUCER";
+ public static final String VAR_API_KEY = "HOP_LINEAGE_OPENLINEAGE_API_KEY";
+ public static final String VAR_CONNECT_TIMEOUT_MS = "HOP_LINEAGE_OPENLINEAGE_CONNECT_TIMEOUT_MS";
+ public static final String VAR_READ_TIMEOUT_MS = "HOP_LINEAGE_OPENLINEAGE_READ_TIMEOUT_MS";
+ public static final String VAR_BUFFER_SIZE = "HOP_LINEAGE_OPENLINEAGE_BUFFER_SIZE";
+ public static final String VAR_MAX_RETRIES = "HOP_LINEAGE_OPENLINEAGE_MAX_RETRIES";
+ public static final String VAR_RETRY_BACKOFF_MS = "HOP_LINEAGE_OPENLINEAGE_RETRY_BACKOFF_MS";
+ public static final String VAR_OVERFLOW_POLICY = "HOP_LINEAGE_OPENLINEAGE_OVERFLOW_POLICY";
+ public static final String VAR_ENQUEUE_TIMEOUT_MS = "HOP_LINEAGE_OPENLINEAGE_ENQUEUE_TIMEOUT_MS";
+ public static final String VAR_SHUTDOWN_DRAIN_MS = "HOP_LINEAGE_OPENLINEAGE_SHUTDOWN_DRAIN_MS";
+ public static final String VAR_METRICS_INTERVAL_MS =
+ "HOP_LINEAGE_OPENLINEAGE_METRICS_INTERVAL_MS";
+ public static final String VAR_TRUSTSTORE_PATH = "HOP_LINEAGE_OPENLINEAGE_TRUSTSTORE_PATH";
+ public static final String VAR_TRUSTSTORE_PASSWORD =
+ "HOP_LINEAGE_OPENLINEAGE_TRUSTSTORE_PASSWORD";
+ public static final String VAR_KEYSTORE_TYPE = "HOP_LINEAGE_OPENLINEAGE_KEYSTORE_TYPE";
+ public static final String VAR_SQL_PARSE = "HOP_LINEAGE_OPENLINEAGE_SQL_PARSE";
+ public static final String VAR_FILE_SPEC_NAMING = "HOP_LINEAGE_OPENLINEAGE_FILE_SPEC_NAMING";
+
+ private static final String DEFAULT_NAMESPACE = "hop";
+ private static final String DEFAULT_PRODUCER =
+ "https://github.com/apache/hop/tree/main/plugins/tech/openlineage";
+ private static final int DEFAULT_CONNECT_TIMEOUT_MS = 5_000;
+ private static final int DEFAULT_READ_TIMEOUT_MS = 30_000;
+ private static final int DEFAULT_BUFFER_SIZE = 10_000;
+ private static final int DEFAULT_MAX_RETRIES = 3;
+ private static final long DEFAULT_RETRY_BACKOFF_MS = 500;
+
+ /**
+ * Drop rather than block by default: lineage is an observation of the pipeline and must never
+ * become a participant in it. The dispatcher's caller is the lineage hub's single dispatcher
+ * thread, so waiting there for an unreachable collector delays every pipeline completion that is
+ * waiting on a hub flush. Deployments that would rather lose throughput than lose lineage can opt
+ * into {@code BLOCK}, which is itself bounded by {@link #VAR_ENQUEUE_TIMEOUT_MS}.
+ */
+ private static final OverflowPolicy DEFAULT_OVERFLOW_POLICY = OverflowPolicy.DROP;
+
+ private static final long DEFAULT_SHUTDOWN_DRAIN_MS = 30_000;
+ private static final long DEFAULT_ENQUEUE_TIMEOUT_MS =
+ OpenLineageAsyncDispatcher.DEFAULT_ENQUEUE_TIMEOUT_MS;
+ private static final long DEFAULT_METRICS_INTERVAL_MS = 0; // 0 = periodic metrics off
+ private static final String DEFAULT_KEYSTORE_TYPE = "PKCS12";
+ private static final boolean DEFAULT_SQL_PARSE = true;
+ // Off by default: spec naming changes existing file dataset identities (see the identity
+ // contract).
+ private static final boolean DEFAULT_FILE_SPEC_NAMING = false;
+
+ private final String collectorUrl;
+ private final String namespace;
+ private final String producer;
+ private final String apiKey;
+ private final int connectTimeoutMs;
+ private final int readTimeoutMs;
+ private final int bufferSize;
+ private final int maxRetries;
+ private final long retryBackoffMs;
+ private final OverflowPolicy overflowPolicy;
+ private final long enqueueTimeoutMs;
+ private final long shutdownDrainMs;
+ private final long metricsIntervalMs;
+ private final String trustStorePath;
+ private final String trustStorePassword;
+ private final String keyStoreType;
+ private final boolean sqlParseEnabled;
+ private final boolean fileSpecNaming;
+
+ private OpenLineageSinkConfig(
+ String collectorUrl,
+ String namespace,
+ String producer,
+ String apiKey,
+ int connectTimeoutMs,
+ int readTimeoutMs,
+ int bufferSize,
+ int maxRetries,
+ long retryBackoffMs,
+ OverflowPolicy overflowPolicy,
+ long enqueueTimeoutMs,
+ long shutdownDrainMs,
+ long metricsIntervalMs,
+ String trustStorePath,
+ String trustStorePassword,
+ String keyStoreType,
+ boolean sqlParseEnabled,
+ boolean fileSpecNaming) {
+ this.collectorUrl = collectorUrl;
+ this.namespace = namespace;
+ this.producer = producer;
+ this.apiKey = apiKey;
+ this.connectTimeoutMs = connectTimeoutMs;
+ this.readTimeoutMs = readTimeoutMs;
+ this.bufferSize = bufferSize;
+ this.maxRetries = maxRetries;
+ this.retryBackoffMs = retryBackoffMs;
+ this.overflowPolicy = overflowPolicy;
+ this.enqueueTimeoutMs = enqueueTimeoutMs;
+ this.shutdownDrainMs = shutdownDrainMs;
+ this.metricsIntervalMs = metricsIntervalMs;
+ this.trustStorePath = trustStorePath;
+ this.trustStorePassword = trustStorePassword;
+ this.keyStoreType = keyStoreType;
+ this.sqlParseEnabled = sqlParseEnabled;
+ this.fileSpecNaming = fileSpecNaming;
+ }
+
+ public static OpenLineageSinkConfig fromVariables(IVariables variables) {
+ String url = variables.getVariable(VAR_URL, "");
+ if (StringUtils.isBlank(url)) {
+ throw new IllegalArgumentException(
+ VAR_URL
+ + " must be set to the OpenLineage collector URL "
+ + "(e.g. http://marquez-api:5000/api/v1/lineage)");
+ }
+ url = url.trim();
+ validateHttpUrl(url);
+ String namespace = variables.getVariable(VAR_NAMESPACE, DEFAULT_NAMESPACE);
+ String producer = variables.getVariable(VAR_PRODUCER, DEFAULT_PRODUCER);
+ String apiKey = variables.getVariable(VAR_API_KEY, "");
+ int connectTimeout =
+ parsePositiveInt(
+ variables.getVariable(VAR_CONNECT_TIMEOUT_MS, null), DEFAULT_CONNECT_TIMEOUT_MS);
+ int readTimeout =
+ parsePositiveInt(variables.getVariable(VAR_READ_TIMEOUT_MS, null), DEFAULT_READ_TIMEOUT_MS);
+ int bufferSize =
+ parsePositiveInt(variables.getVariable(VAR_BUFFER_SIZE, null), DEFAULT_BUFFER_SIZE);
+ int maxRetries =
+ parseNonNegativeInt(variables.getVariable(VAR_MAX_RETRIES, null), DEFAULT_MAX_RETRIES);
+ long retryBackoff =
+ parsePositiveLong(
+ variables.getVariable(VAR_RETRY_BACKOFF_MS, null), DEFAULT_RETRY_BACKOFF_MS);
+ OverflowPolicy overflowPolicy =
+ parseOverflowPolicy(variables.getVariable(VAR_OVERFLOW_POLICY, null));
+ long enqueueTimeout =
+ parsePositiveLong(
+ variables.getVariable(VAR_ENQUEUE_TIMEOUT_MS, null), DEFAULT_ENQUEUE_TIMEOUT_MS);
+ long shutdownDrain =
+ parsePositiveLong(
+ variables.getVariable(VAR_SHUTDOWN_DRAIN_MS, null), DEFAULT_SHUTDOWN_DRAIN_MS);
+ long metricsInterval =
+ parseNonNegativeLong(
+ variables.getVariable(VAR_METRICS_INTERVAL_MS, null), DEFAULT_METRICS_INTERVAL_MS);
+ String trustStorePath = variables.getVariable(VAR_TRUSTSTORE_PATH, "");
+ String trustStorePassword = variables.getVariable(VAR_TRUSTSTORE_PASSWORD, "");
+ String keyStoreType = variables.getVariable(VAR_KEYSTORE_TYPE, DEFAULT_KEYSTORE_TYPE);
+ boolean sqlParse = parseBoolean(variables.getVariable(VAR_SQL_PARSE, null), DEFAULT_SQL_PARSE);
+ boolean fileSpecNaming =
+ parseBoolean(variables.getVariable(VAR_FILE_SPEC_NAMING, null), DEFAULT_FILE_SPEC_NAMING);
+ return new OpenLineageSinkConfig(
+ url,
+ StringUtils.defaultIfBlank(namespace, DEFAULT_NAMESPACE).trim(),
+ StringUtils.defaultIfBlank(producer, DEFAULT_PRODUCER).trim(),
+ StringUtils.isBlank(apiKey) ? null : apiKey.trim(),
+ connectTimeout,
+ readTimeout,
+ bufferSize,
+ maxRetries,
+ retryBackoff,
+ overflowPolicy,
+ enqueueTimeout,
+ shutdownDrain,
+ metricsInterval,
+ StringUtils.isBlank(trustStorePath) ? null : trustStorePath.trim(),
+ StringUtils.isBlank(trustStorePassword) ? null : trustStorePassword.trim(),
+ StringUtils.defaultIfBlank(keyStoreType, DEFAULT_KEYSTORE_TYPE).trim(),
+ sqlParse,
+ fileSpecNaming);
+ }
+
+ private static boolean parseBoolean(String raw, boolean defaultValue) {
+ if (StringUtils.isBlank(raw)) {
+ return defaultValue;
+ }
+ String value = raw.trim();
+ if ("Y".equalsIgnoreCase(value)
+ || "true".equalsIgnoreCase(value)
+ || "yes".equalsIgnoreCase(value)
+ || "1".equals(value)) {
+ return true;
+ }
+ if ("N".equalsIgnoreCase(value)
+ || "false".equalsIgnoreCase(value)
+ || "no".equalsIgnoreCase(value)
+ || "0".equals(value)) {
+ return false;
+ }
+ return defaultValue;
+ }
+
+ private static long parseNonNegativeLong(String raw, long defaultValue) {
+ if (StringUtils.isBlank(raw)) {
+ return defaultValue;
+ }
+ try {
+ long value = Long.parseLong(raw.trim());
+ return value >= 0 ? value : defaultValue;
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ private static void validateHttpUrl(String url) {
+ try {
+ URI uri = new URI(url);
+ String scheme = uri.getScheme();
+ if (scheme == null
+ || (!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https"))
+ || uri.getHost() == null) {
+ throw new IllegalArgumentException(
+ VAR_URL + " must be an absolute http(s) URL, was: " + url);
+ }
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(VAR_URL + " is not a valid URL: " + url, e);
+ }
+ }
+
+ private static OverflowPolicy parseOverflowPolicy(String raw) {
+ if (StringUtils.isBlank(raw)) {
+ return DEFAULT_OVERFLOW_POLICY;
+ }
+ try {
+ return OverflowPolicy.valueOf(raw.trim().toUpperCase(java.util.Locale.ROOT));
+ } catch (IllegalArgumentException e) {
+ return DEFAULT_OVERFLOW_POLICY;
+ }
+ }
+
+ private static int parseNonNegativeInt(String raw, int defaultValue) {
+ if (StringUtils.isBlank(raw)) {
+ return defaultValue;
+ }
+ try {
+ int value = Integer.parseInt(raw.trim());
+ return value >= 0 ? value : defaultValue;
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ private static long parsePositiveLong(String raw, long defaultValue) {
+ if (StringUtils.isBlank(raw)) {
+ return defaultValue;
+ }
+ try {
+ long value = Long.parseLong(raw.trim());
+ return value > 0 ? value : defaultValue;
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ private static int parsePositiveInt(String raw, int defaultValue) {
+ if (StringUtils.isBlank(raw)) {
+ return defaultValue;
+ }
+ try {
+ int value = Integer.parseInt(raw.trim());
+ return value > 0 ? value : defaultValue;
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ public String getCollectorUrl() {
+ return collectorUrl;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String getProducer() {
+ return producer;
+ }
+
+ public String getApiKey() {
+ return apiKey;
+ }
+
+ public int getConnectTimeoutMs() {
+ return connectTimeoutMs;
+ }
+
+ public int getReadTimeoutMs() {
+ return readTimeoutMs;
+ }
+
+ public int getBufferSize() {
+ return bufferSize;
+ }
+
+ public int getMaxRetries() {
+ return maxRetries;
+ }
+
+ public long getRetryBackoffMs() {
+ return retryBackoffMs;
+ }
+
+ public OverflowPolicy getOverflowPolicy() {
+ return overflowPolicy;
+ }
+
+ /** Ceiling on how long {@code BLOCK} waits for outbound-buffer capacity before dropping. */
+ public long getEnqueueTimeoutMs() {
+ return enqueueTimeoutMs;
+ }
+
+ public long getShutdownDrainMs() {
+ return shutdownDrainMs;
+ }
+
+ public long getMetricsIntervalMs() {
+ return metricsIntervalMs;
+ }
+
+ public String getTrustStorePath() {
+ return trustStorePath;
+ }
+
+ public String getTrustStorePassword() {
+ return trustStorePassword;
+ }
+
+ public String getKeyStoreType() {
+ return keyStoreType;
+ }
+
+ /** Whether Table Input / Execute SQL statements are parsed to recover their relational tables. */
+ public boolean isSqlParseEnabled() {
+ return sqlParseEnabled;
+ }
+
+ /** Whether file datasets use OpenLineage spec naming (VFS scheme namespace + path) vs. legacy. */
+ public boolean isFileSpecNaming() {
+ return fileSpecNaming;
+ }
+}
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/RelationalColumnLineageCorrelator.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/RelationalColumnLineageCorrelator.java
new file mode 100644
index 0000000000..64d8b2075f
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/RelationalColumnLineageCorrelator.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.hop.core.util.Utils;
+import org.apache.hop.lineage.model.RelationalTable;
+import org.apache.hop.lineage.model.RelationalWriteColumn;
+
+/**
+ * Correlates relational reads and writes within a pipeline run to produce column-level lineage for
+ * the stream path — e.g. a Table Input {@code SELECT id, amount FROM source} feeding a Table Output
+ * that writes {@code target(id, amount)}.
+ *
+ * <p>Each read registers, per transform, the mapping from its output stream fields to the source
+ * table column they came from (from the read's parsed SQL column lineage). Each write then carries,
+ * per target column, the stream field and the transform that produced it ({@code
+ * IValueMeta.getOrigin()}). Matching the write column's origin transform to a registered read
+ * resolves {@code targetColumn → sourceColumn}, even through pass-through transforms (which
+ * preserve the field origin). It is deliberately conservative: a column whose origin is not a
+ * registered read (a computed field, a join without a resolvable source, …) yields no lineage
+ * rather than a guess.
+ *
+ * <p>State is held per pipeline run in a bounded least-recently-used map. It is deliberately not
+ * dropped when the run reports COMPLETE: a transform emits its relational I/O when it finishes, and
+ * that can reach the sink after the pipeline's own completion event, so clearing on completion
+ * silently cost those writes their column lineage. Eviction by age instead of by run lifecycle
+ * keeps memory bounded without depending on the order events happen to arrive in.
+ */
+final class RelationalColumnLineageCorrelator {
+
+ /**
+ * How many pipeline runs to keep read state for. Well above any realistic number of concurrently
+ * running pipelines, and small enough that the retained mappings stay negligible.
+ */
+ static final int MAX_RUNS = 128;
+
+ /** What a single read exposes: how each stream field maps back to a source table column. */
+ private static final class ReadInfo {
+ /** Stream field name → source column reference, from the read's parsed column lineage. */
+ private final Map<String, RelationalSqlParser.FieldRef> byStreamField = new LinkedHashMap<>();
+
+ /** The single source table, used to name-match stream fields the parser did not resolve. */
+ private final RelationalTable singleSource;
+
+ ReadInfo(List<RelationalSqlParser.ColumnEdge> columnEdges, List<RelationalTable> inputs) {
+ for (RelationalSqlParser.ColumnEdge edge : columnEdges) {
+ if (edge.outputField() != null && !edge.inputs().isEmpty()) {
+ byStreamField.putIfAbsent(edge.outputField(), edge.inputs().get(0));
+ }
+ }
+ this.singleSource = inputs != null && inputs.size() == 1 ? inputs.get(0) : null;
+ }
+
+ RelationalSqlParser.FieldRef sourceFor(String streamField) {
+ RelationalSqlParser.FieldRef ref = byStreamField.get(streamField);
+ if (ref != null) {
+ return ref;
+ }
+ // Fall back to a direct column of the sole source table (name match) when the parser gave no
+ // per-column lineage for this field (e.g. SELECT *).
+ if (singleSource != null && !Utils.isEmpty(streamField)) {
+ return new RelationalSqlParser.FieldRef(singleSource, streamField);
+ }
+ return null;
+ }
+ }
+
+ /** Least-recently-used run state, oldest run evicted once {@link #MAX_RUNS} is exceeded. */
+ private static final class RunCache extends LinkedHashMap<String, Map<String, ReadInfo>> {
+ RunCache() {
+ super(16, 0.75f, true);
+ }
+
+ @Override
+ protected boolean removeEldestEntry(Map.Entry<String, Map<String, ReadInfo>> eldest) {
+ return size() > MAX_RUNS;
+ }
+ }
+
+ private final Map<String, Map<String, ReadInfo>> readsByRun =
+ Collections.synchronizedMap(new RunCache());
+
+ /**
+ * Registers a read's per-field source columns under its run and transform. No-op when the run,
+ * transform, or column information is missing.
+ */
+ void registerRead(
+ String runId,
+ String transformName,
+ List<RelationalSqlParser.ColumnEdge> columnEdges,
+ List<RelationalTable> inputs) {
+ if (Utils.isEmpty(runId) || Utils.isEmpty(transformName)) {
+ return;
+ }
+ readsByRun
+ .computeIfAbsent(runId, k -> new ConcurrentHashMap<>())
+ .put(transformName, new ReadInfo(columnEdges, inputs));
+ }
+
+ /**
+ * Resolves each written column back to its source column via the read registered for its origin
+ * transform, producing {@link RelationalSqlParser.ColumnEdge}s ({@code targetColumn ←
+ * sourceColumn}) for the sink to render as a {@code columnLineage} facet. Columns whose origin is
+ * not a registered read are omitted.
+ */
+ List<RelationalSqlParser.ColumnEdge> correlate(
+ String runId, List<RelationalWriteColumn> writeColumns) {
+ if (Utils.isEmpty(runId) || writeColumns == null || writeColumns.isEmpty()) {
+ return List.of();
+ }
+ Map<String, ReadInfo> reads = readsByRun.get(runId);
+ if (reads == null || reads.isEmpty()) {
+ return List.of();
+ }
+ List<RelationalSqlParser.ColumnEdge> edges = new ArrayList<>();
+ for (RelationalWriteColumn column : writeColumns) {
+ if (Utils.isEmpty(column.getTargetColumn()) || Utils.isEmpty(column.getOriginTransform())) {
+ continue;
+ }
+ ReadInfo read = reads.get(column.getOriginTransform());
+ if (read == null) {
+ continue;
+ }
+ RelationalSqlParser.FieldRef source = read.sourceFor(column.getStreamField());
+ if (source == null || Utils.isEmpty(source.field())) {
+ continue;
+ }
+ edges.add(new RelationalSqlParser.ColumnEdge(column.getTargetColumn(), List.of(source)));
+ }
+ return edges;
+ }
+}
diff --git a/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/RelationalSqlParser.java b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/RelationalSqlParser.java
new file mode 100644
index 0000000000..28dbeb82d0
--- /dev/null
+++ b/plugins/tech/openlineage/src/main/java/org/apache/hop/lineage/openlineage/RelationalSqlParser.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lineage.openlineage;
+
+import io.openlineage.sql.ColumnLineage;
+import io.openlineage.sql.ColumnMeta;
+import io.openlineage.sql.DbTableMeta;
+import io.openlineage.sql.OpenLineageSql;
+import io.openlineage.sql.SqlMeta;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.util.Utils;
+import org.apache.hop.lineage.model.RelationalTable;
+
+/**
+ * Extracts the input and output tables of a SQL statement using the OpenLineage SQL parser ({@code
+ * openlineage-sql-java}: a Rust core reached over JNI). Used to recover the source tables of a
+ * Table Input {@code SELECT} — which the Hop engine cannot know without parsing — into the neutral
+ * {@link RelationalTable} identity the mapper turns into OpenLineage datasets.
+ *
+ * <p>Strictly best-effort: a disabled parser, a blank statement, an unavailable native library, a
+ * statement the parser rejects, or any native error all yield {@link Tables#EMPTY} and never throw.
+ * A read whose SQL cannot be parsed therefore produces no relational input lineage rather than
+ * failing delivery.
+ */
+final class RelationalSqlParser {
+
+ private final boolean enabled;
+ private final ILogChannel log;
+
+ private RelationalSqlParser(boolean enabled, ILogChannel log) {
+ this.enabled = enabled;
+ this.log = log;
+ }
+
+ /** Creates a parser; when {@code enabled} is false every {@link #parse} returns empty. */
+ static RelationalSqlParser create(boolean enabled, ILogChannel log) {
+ return new RelationalSqlParser(enabled, log);
+ }
+
+ /**
+ * The tables a statement reads ({@code inputs}) and writes ({@code outputs}), plus
+ * per-output-field {@code columnLineage} when the parser resolved it (e.g. {@code INSERT …
+ * SELECT}).
+ */
+ record Tables(
+ List<RelationalTable> inputs, List<RelationalTable> outputs, List<ColumnEdge> columnLineage) {
+ static final Tables EMPTY = new Tables(List.of(), List.of(), List.of());
+
+ boolean isEmpty() {
+ return inputs.isEmpty() && outputs.isEmpty();
+ }
+ }
+
+ /** One output field and the input table columns it derives from. */
+ record ColumnEdge(String outputField, List<FieldRef> inputs) {}
+
+ /** A reference to a column of a specific relational table. */
+ record FieldRef(RelationalTable table, String field) {}
+
+ /**
+ * Parses {@code sql} for the given database {@code dialect} (e.g. {@code postgres}, {@code
+ * mysql}; may be null for the parser's default). Returns the referenced tables, or {@link
+ * Tables#EMPTY} on any failure.
+ */
+ Tables parse(String sql, String dialect) {
+ if (!enabled || Utils.isEmpty(sql)) {
+ return Tables.EMPTY;
... 2926 lines suppressed ...