Area: Product
Sub-Area: Governance
Applies to: OSS + Cloud
Issue
Tags added through the UI, the API or ingestion don't appear on datasets or columns, or they disappear after an ingestion run. The usual causes are a wrong tag URN, missing permissions, or an ingestion transformer that replaces the tags already in DataHub.
You Might Be Asking
- Why aren't my tags showing up in DataHub?
- How do I stop ingestion from removing tags I added in the UI?
- What is the correct format for a tag URN?
- How do I add a tag to a column?
Cause
-
Wrong tag URN. A tag URN has the form
urn:li:tag:<name>. A bare name orurn:li:tags:<name>is not a tag URN. - Missing privileges. "Edit Tags" covers tags on an asset. Tags on dataset columns need the separate "Edit Dataset Column Tags" privilege.
-
A tag transformer replaces the tags. Tag transformers have a
semanticssetting. The default isOVERWRITE, which replaces the dataset's tags in DataHub with the transformer's tags. Tags added in the UI are lost.PATCHkeeps the tags already in DataHub and adds the transformer's tags. -
Misplaced or invalid recipe keys.
transformersis a top-level recipe key next tosourceandsink. Unknown top-level keys fail validation.pattern_add_dataset_tagstakestag_pattern, nottag_urns. -
A pattern that doesn't match.
pattern_add_dataset_tagstests each regex against the dataset URN from the start of the URN. A pattern that doesn't begin with.*can miss the dataset.
Solution
- Check the tag URN format:
# Correct
urn:li:tag:YourTagName
# Not tag URNs
YourTagName
urn:li:tags:YourTagName
- Add tags to a dataset with the GraphQL
addTagsmutation. It returns a Boolean, so it needs no selection set:
mutation addTags {
addTags(
input: {
tagUrns: ["urn:li:tag:PII", "urn:li:tag:Sensitive"],
resourceUrn: "urn:li:dataset:(urn:li:dataPlatform:snowflake,db.schema.table,PROD)"
}
)
}
- Add a tag to a column with the same mutation. Set
subResourceTypetoDATASET_FIELDandsubResourceto the column's field path:
mutation addColumnTag {
addTags(
input: {
tagUrns: ["urn:li:tag:PII"],
resourceUrn: "urn:li:dataset:(urn:li:dataPlatform:snowflake,db.schema.table,PROD)",
subResourceType: DATASET_FIELD,
subResource: "column_name"
}
)
}
See the Tag API tutorial for GraphQL and Python examples. In the Python SDK, DatasetPatchBuilder(...).for_field(field_path) returns a helper with add_tag and remove_tag. Use a patch like this instead of building and emitting a whole EditableSchemaMetadata aspect.
- Keep UI tags when ingestion adds its own tags. Put the transformer at the top level of the recipe and set
semantics: PATCH:
source:
# your existing source settings
transformers:
- type: simple_add_dataset_tags
config:
semantics: PATCH
tag_urns: ["urn:li:tag:AutoGenerated"]
To add tags by pattern, use pattern_add_dataset_tags with tag_pattern.rules. Each rule maps a regex to a list of tag URNs. DataHub matches the regex against the dataset URN with re.match, so it matches from the start of the URN. Use a form like .*orders.* to match anywhere in the URN. Use ^...$ for an exact match. By default only the first matching rule applies (first_match_only is true). Set first_match_only: false to apply every matching rule.
transformers:
- type: pattern_add_dataset_tags
config:
semantics: PATCH
tag_pattern:
rules:
".*table.*": ["urn:li:tag:AutoGenerated"]
See simple_add_dataset_tags and pattern_add_dataset_tags.
-
Check privileges in a Metadata policy. Give the user "Edit Tags" for asset tags and "Edit Dataset Column Tags" for column tags. See Policies.
-
If you filter search by a tag, note that the Tags filter on datasets also matches datasets where the tag is only on a column.