Area: Product
Sub-Area: Metadata
Applies to: OSS + Cloud
Issue
Custom properties that you added to a dataset do not show in the DataHub UI. Or they show, and then the next ingestion run removes them. Sometimes the dataset description is also gone after you add custom properties.
You Might Be Asking
- How do I add custom properties to a dataset?
- Where do custom properties appear in the UI?
- Can I prevent ingestion from overwriting custom properties?
- Ingestion overwrote my custom properties. Can I get the previous datasetProperties back?
Cause
DataHub stores custom properties in the dataset's datasetProperties aspect. The same aspect holds the dataset name and description.
- When you emit a new
DatasetPropertiesClass, DataHub replaces the stored aspect with it. The description, the name and each custom property that your new aspect does not include are removed. - Most ingestion sources, Snowflake included, write the whole
datasetPropertiesaspect on each run by default. This replaces the custom properties that you added through the API.
Solution
An ingestion run can replace custom properties. To get them back, read an earlier version of the aspect and emit it again.
DataHub saves each previous value of datasetProperties as a version. Version 0 is the current value. Earlier versions start at 1, the oldest, and go up. The highest number is the most recent previous value.
To restore an earlier value, use the Python SDK:
- Read
version=0and save it. The restore replaces the whole aspect, including the name and the description. - Read an earlier version:
old = graph.get_aspect(urn, DatasetPropertiesClass, version=N). - Emit the earlier version:
graph.emit_mcp(MetadataChangeProposalWrapper(entityUrn=urn, aspect=old)).
The get_aspect call returns None if retention deleted that version. By default, retention keeps 20 versions of each aspect.
The next ingestion run that writes datasetProperties replaces the restored value again. To stop this, also apply one of the fixes below.
The full steps are in Viewing Metadata Change History and Previous Aspect Versions and Aspect Versioning.
To add custom properties with the Python SDK, use a patch:
- Create a
DatasetPatchBuilder(dataset_urn). - Call
add_custom_property(key, value)for each property. - Emit each item from
patch_builder.build()withemit.
The patch changes only the keys that you add. The description, the name and the other custom properties stay. The full example is in Add Custom Properties programmatically.
Do not emit a new DatasetPropertiesClass to add custom properties. It removes the description, the name and all custom properties that it does not include.
emit_mcp takes one MetadataChangeProposalWrapper(entityUrn=..., aspect=...) object. It has no entity_urn, aspect_name or aspect arguments.
For Snowflake, set incremental_properties: true under source.config. The source then sends datasetProperties as a patch, so the custom properties stored in DataHub stay. The Unity Catalog, Glue and Dremio sources have the same option. Its default is false.
For any source, you can also keep the stored custom properties with a dataset transformer. Add a transformer with semantics: PATCH to the recipe:
source:
type: snowflake
config:
# your source config
transformers:
- type: simple_add_dataset_properties
config:
semantics: PATCH
properties:
source_system: snowflake
- Put
transformersat the top level of the recipe, next tosourceandsink. Do not put it undersource.config, or the recipe fails validation. - With
semantics: PATCH, the transformer reads the custom properties stored in DataHub and merges them into what ingestion writes. If a key exists in both, the ingested value wins. -
semantics: PATCHreads from DataHub. The recipe needs adatahub-restsink or adatahub_apisection. UI ingestion already has one. -
replace_existingdoes not keep stored properties. It only removes the custom properties that the source sent. Its default isfalse. - To choose properties for each dataset in code, use
add_dataset_propertieswithadd_properties_resolver_class. The options are in Simple Add Dataset datasetProperties.
For metadata that you manage outside ingestion, you can use structured properties. They are stored in a separate aspect, structuredProperties, so a datasetProperties write does not replace them. They also have types and allowed values.
To see custom properties, open the dataset and select the Properties tab. The tab shows custom properties and visible structured properties in one list. With GraphQL, read dataset(urn: "...") { properties { customProperties { key value } } }.
Related Documentation
- Custom Properties
- Simple Add Dataset datasetProperties
- Relationship Between replace_existing and semantics
- Structured Properties
- Dataset
- Viewing Metadata Change History and Previous Aspect Versions
- Aspect Versioning
Tags: custom-properties, metadata, properties, api, transformers, key-value, dataset-properties, structured-properties