Implementation:Datahub project Datahub HasGlossaryTerms Mixin
| Knowledge Sources | |
|---|---|
| Domains | Java_SDK, Metadata_Management |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
Description
HasGlossaryTerms is a mixin interface in the DataHub Java SDK V2 that provides glossary term operations for entities. Entities implementing this interface can have glossary terms attached for semantic meaning and governance purposes.
The interface supports two mutation strategies:
- Patch-based (
addTerm()/removeTerm()): UsesGlossaryTermsPatchBuilderfor incremental additions or removals, enabling safe concurrent modifications. - Full replacement (
setTerms()): Creates a completeMetadataChangeProposalWrapperreplacing all existing terms, clearing any pending patches.
The interface uses a self-bounded generic pattern (T extends Entity & HasGlossaryTerms<T>) for fluent API chaining.
Usage
Entity classes implement this interface to gain glossary term management. addTerm() and removeTerm() accumulate patch operations that are applied at save time, while setTerms() performs a full aspect replacement. getTerms() retrieves the current list of term associations via lazy loading.
Code Reference
Source Location
metadata-integration/java/datahub-client/src/main/java/datahub/client/v2/entity/HasGlossaryTerms.java
Signature
public interface HasGlossaryTerms<T extends Entity & HasGlossaryTerms<T>> {
@Nonnull
default T addTerm(@Nonnull String termUrn)
@Nonnull
default T addTerm(@Nonnull GlossaryTermUrn termUrn)
@Nonnull
default T removeTerm(@Nonnull String termUrn)
@Nonnull
default T removeTerm(@Nonnull GlossaryTermUrn termUrn)
@Nonnull
default T setTerms(@Nonnull List<String> termUrns)
default List<GlossaryTermAssociation> getTerms()
}
Import
import datahub.client.v2.entity.HasGlossaryTerms;
I/O Contract
Inputs
| Method | Parameter | Type | Description |
|---|---|---|---|
| addTerm | termUrn |
String |
URN string of the glossary term to add |
| addTerm | termUrn |
GlossaryTermUrn |
URN object of the glossary term to add |
| removeTerm | termUrn |
String |
URN string of the glossary term to remove |
| removeTerm | termUrn |
GlossaryTermUrn |
URN object of the glossary term to remove |
| setTerms | termUrns |
List<String> |
Complete list of glossary term URN strings to set |
Outputs
| Method | Return Type | Description |
|---|---|---|
| addTerm | T |
The entity itself for fluent chaining |
| removeTerm | T |
The entity itself for fluent chaining |
| setTerms | T |
The entity itself for fluent chaining |
| getTerms | List<GlossaryTermAssociation> (nullable) |
The list of glossary term associations, or null if none present
|
Exceptions:
InvalidUrnException- thrown if a URN string cannot be parsed
Usage Examples
Dataset dataset = Dataset.builder()
.platform("snowflake")
.name("my_table")
.build();
// Add individual terms (patch-based, accumulated)
dataset.addTerm("urn:li:glossaryTerm:CustomerData");
dataset.addTerm("urn:li:glossaryTerm:SensitiveInfo");
// Remove a specific term
dataset.removeTerm("urn:li:glossaryTerm:SensitiveInfo");
// Set all terms at once (full replacement)
dataset.setTerms(Arrays.asList(
"urn:li:glossaryTerm:CustomerData",
"urn:li:glossaryTerm:PII"
));
// Retrieve current terms
List<GlossaryTermAssociation> terms = dataset.getTerms();
Related Pages
- Datahub_project_Datahub_HasOwners_Mixin - Mixin for ownership management (similar patch/replace pattern)
- Datahub_project_Datahub_HasDomains_Mixin - Mixin for domain assignment
- Datahub_project_Datahub_HasStructuredProperties_Mixin - Mixin for structured property management
- Datahub_project_Datahub_PatchTransformer - Interface for transforming patch MCPs