Area: Product
Sub-Area: Governance
Applies to: OSS + Cloud
Issue
Glossary terms you created in DataHub don't show on datasets or columns, or the terms you added by hand disappear after an ingestion run. The usual cause is an ingestion transformer that uses the default semantics, OVERWRITE, which replaces the terms already on the asset.
You Might Be Asking
- How do I link a glossary term to a dataset or column?
- Why are my glossary term associations disappearing after ingestion?
- Can I bulk-assign glossary terms?
Cause
Transformers such as pattern_add_dataset_terms default to semantics: OVERWRITE. With OVERWRITE, the transformer writes the terms it computed and does not read the terms already on the server. Only semantics: PATCH merges with the glossary terms on the server. Setting replace_existing does not change this.
Solution
A glossary term URN has the form urn:li:glossaryTerm:<id>. The examples below use the custom id revenue, which assumes you created the term with that id. A term created in the UI gets a random UUID as its id unless someone sets a custom id under Advanced in the create dialog. Use the actual URN of your term in every step.
- Create a glossary term.
idis optional (a random UUID is used if you leave it out) andnameis required. The call fails with "This Glossary Term already exists!" if the id is taken, and with "Glossary Term with this name already exists at this level of the Business Glossary" if the name is taken at the same level.
mutation createGlossaryTerm {
createGlossaryTerm(
input: {
id: "revenue",
name: "Revenue",
description: "Total revenue from all sources"
}
)
}
- Link the term to a dataset:
mutation addTerms {
addTerms(
input: {
termUrns: ["urn:li:glossaryTerm:revenue"],
resourceUrn: "urn:li:dataset:(urn:li:dataPlatform:snowflake,db.schema.sales,PROD)"
}
)
}
- Link the term to a column. Set
subResourceTypetoDATASET_FIELDandsubResourceto the column's field path:
mutation addTerms {
addTerms(
input: {
termUrns: ["urn:li:glossaryTerm:revenue"],
resourceUrn: "urn:li:dataset:(urn:li:dataPlatform:snowflake,db.schema.sales,PROD)",
subResourceType: DATASET_FIELD,
subResource: "user_name"
}
)
}
In the Python SDK, use dataset["column_name"].add_term(term) and then update the entity through the client. This writes the term to the editable schema layer. In ingestion mode it raises SdkUsageError: "Adding field terms in ingestion mode is not yet supported. Use set_terms instead."
-
To tag many assets at once, use
batchAddTermswithtermUrnsand a list ofresources. -
To keep terms added in the UI or through the API when ingestion runs, set
semantics: PATCHon the transformer.transformersis a top-level recipe key, next tosourceandsink. Insidesource.configthe recipe fails validation.
source:
type: <your source>
config:
# your source settings
transformers:
- type: "pattern_add_dataset_terms"
config:
semantics: PATCH
term_pattern:
rules:
".*revenue.*": ["urn:li:glossaryTerm:revenue"]
".*customer.*": ["urn:li:glossaryTerm:customer"]
Each rule value is a list of term URNs. Rule keys are matched with re.match, which anchors at the start of the string.
Additional Notes
A glossary term can have only one parent, and the parent must be a glossary node (Term Group). Use Term Groups to build a hierarchy.