Skip to content

feat(ingest): add dataproduct_mapping_based_on_tags transformer - #21640

Merged
acrylJonny merged 2 commits into
masterfrom
feat/dataproduct-mapping-based-on-tags
Nov 26, 2026
Merged

acrylJonny merged 2 commits into
masterfrom
feat/dataproduct-mapping-based-on-tags

Conversation

@acrylJonny

@acrylJonny acrylJonny commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds dataproduct_mapping_based_on_tags, mirroring domain_mapping_based_on_tags, so datasets can be assigned to data products from tags already present in DataHub.
  • Reads tags via the graph (get_tags), maps the first matching simple tag name to a data product URN, and patches the product assets through the existing AddDatasetDataProduct path.
  • Documents the transformer and covers match / no-match / config-order / empty / missing-tag cases in unit tests.

Test plan

  • pytest -vv tests/unit/test_transform_dataset.py -k 'dataproduct_mapping_based_on_tags'
  • ./gradlew :metadata-ingestion:lintFix :metadata-ingestion:checkLockFile
  • Confirm recipe usage with a datahub-rest sink against a local DataHub that already has the mapped tags on datasets

Summary by cubic

Adds a dataproduct_mapping_based_on_tags transformer that assigns datasets to data products based on tags already present in DataHub, mirroring the existing domain_mapping_based_on_tags.

  • Reads tags from the graph via get_tags and raises a ConfigurationError when no graph connection is configured.
  • When several mapped tags match, the tag listed first in dataproduct_mapping decides the data product, regardless of the dataset's tag order.
  • Adds the dataset as an asset via the existing AddDatasetDataProduct path using a patch, so current data product memberships are preserved.
  • Documents that tags must already be in DataHub before the run and that removing a tag does not remove the dataset from its data product.
  • Registers the transformer entry point and adds unit tests covering match, no-match, config-order-wins, empty-tags, missing-tags, and no-graph cases.

Written for commit 54f7a85. Summary will update on new commits.

View guided diff Turn on auto-fix

Mirror domain_mapping_based_on_tags so datasets can be assigned to data
products from tags already present in DataHub.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the ingestion PR or Issue related to the ingestion of metadata label Nov 26, 2026
@cursor

cursor Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Introduces a dataproduct_mapping_based_on_tags ingestion transformer so datasets can be linked to data products using tags already stored in DataHub, in the same spirit as domain_mapping_based_on_tags.

The new DatasetTagDataProductMapper delegates to AddDatasetDataProduct: it calls the graph’s get_tags, matches simple tag names (not full tag URNs) against a dataproduct_mapping dict, and assigns the dataset as an asset on the mapped data product with patch semantics. Config key order wins when multiple tags match, and the recipe must have a graph connection (datahub-rest or datahub_api); otherwise init fails with ConfigurationError. Tags applied only in the same ingestion run are not visible until a later run.

The transformer is registered in pyproject.toml and setup.py, documented in the dataset transformer docs, and covered by unit tests (match, no match, first-in-config wins, empty/missing tags, no graph).

Reviewed by Cursor Bugbot for commit 54f7a85. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: shadow. The selection below is computed but not applied; this PR still runs the default matrix (p0).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 44 of 846 tests in 1 batch, predicted longest batch ~2 min
  • Tags: change-type: docs, test-infra; compound: ingestion:connector; entity-scope: dataset; feature-dev: transforms; feature-user: data-products
  • Confidence: HIGH (6 changed files)
  • Classifier reasoning: Adds a new dataset-to-data-product tag-based mapping transformer (ingestion transforms, data products) with unit tests and docs; docs-only changes tagged docs and tests tagged as product feature.
Selected scopes (11 files or classes, 44 tests)
  • tests/e2e/assertions/dbt_test_results_test.py
  • tests/e2e/authorization/test_aspect_write_auth.py
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/dataproduct/test_dataproduct.py
  • tests/e2e/dataproduct/test_dataproduct_hierarchy_delete.py
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/odcs/test_odcs_ingestion.py
  • tests/e2e/read_only/test_dataproduct.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

commit 54f7a85 · workflow run

@datahub-connector-tests

datahub-connector-tests Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Connector Tests Results

All connector tests passed for commit 54f7a85

View full test logs →

To skip connector tests, add the skip-connector-tests label (org members only).

Autogenerated by the connector-tests CI pipeline.

@max-datahub max-datahub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving — small, opt-in, additive, and it reuses the tested AddDatasetDataProduct patch path. A few non-blocking notes:

  1. First-matching-tag wins. multipleDataProductsPerAsset defaults to true on the server, so a dataset tagged with two mapped tags could legitimately belong to both products, but only one is added (chosen by tag order on the dataset, not config order). The sibling domain_mapping_based_on_tags adds every matched domain. Was first-wins intentional? Switching to "add to all matched products" later would be additive, so this doesn't need to block.
  2. Fail fast without a graph. assert ctx.graph lives inside the callback, so a recipe without a graph connection only fails at end-of-stream, after the whole source has run, with a bare AssertionError. Checking in __init__/create and raising a ConfigurationError (like AddDomain.raise_ctx_configuration_error) would surface it immediately. Fine as a follow-up.
  3. Docs.
    • Tags are read from GMS before the sink is flushed, and tags in the current run's stream aren't consulted. So tags the source emits in the same run (e.g. platform tag extraction) only take effect on the next run. Worth saying "tags must already exist in DataHub before the run".
    • Removing a tag doesn't remove the dataset from the data product (additive only).
    • "Datasets already in a data product stay in it" holds only when multipleDataProductsPerAsset is enabled (the default).
    • Minor: the two paragraphs between "would look like this:" and the YAML block read better after it.

Also, the test plan's live datahub-rest check is still unticked. Was it run? The unit tests stub get_tags.

  • Claude (on behalf of Max)

… a graph

- When a dataset has several mapped tags, the tag listed first in
  dataproduct_mapping now decides its data product, rather than the
  order of the dataset's tags.
- Raise a ConfigurationError when the transformer is created without a
  DataHub graph, instead of an AssertionError at the end of the stream.
- Document that tags must already be in DataHub before the run, that
  removing a tag does not remove the dataset from the data product, and
  when existing memberships are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acrylJonny

Copy link
Copy Markdown
Collaborator Author

Thanks. All points are addressed in 54f7a85.

  1. Several mapped tags: a dataset still goes to one data product. The parent AddDatasetDataProduct callback returns one URN, and pattern_add_dataset_dataproduct rejects a dataset mapped to two products, so one product matches the other data product transformers. You're right that tag order on the dataset was the wrong tiebreak, though. The tag listed first in dataproduct_mapping now wins, so the user controls it. The test was renamed and now asserts this. Adding to all matched products can follow later if wanted, since it would be additive.
  2. Fail fast: __init__ raises a ConfigurationError when ctx.graph is None, with the same guidance as AddDomain. A recipe with a console sink now fails at "Failed to configure transformers", before the source runs. A unit test covers it.
  3. Docs: all four done.
    • The tags must already be in DataHub before the run. Tags emitted in the same run are seen on the next run.
    • Removing a tag doesn't remove the dataset from the data product.
    • Existing memberships are kept only when multiple data products per asset is enabled (the default, MULTIPLE_DATA_PRODUCTS_PER_ASSET).
    • The two paragraphs now come after the YAML.

Live check, now ticked: I ran it with a file source and a datahub-rest sink against a local DataHub. Three datasets:

  • One had both mapped tags, with its tags in the opposite order to the config. It was added to the config-first product only.
  • One was already in another product. It was added to its mapped product and stayed in the other one.
  • One had no tags. It was left alone.

The 6 transformer unit tests pass. ruff, mypy and markdown prettier are clean.

  • Claude (on behalf of Jonny)

@acrylJonny
acrylJonny merged commit f293862 into master Nov 26, 2026
96 checks passed
@acrylJonny
acrylJonny deleted the feat/dataproduct-mapping-based-on-tags branch November 26, 2026 11:29

This branch was successfully deployed

1 active deployment
Preview — 54f7a85d Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ingestion PR or Issue related to the ingestion of metadata

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants