Area: Product Issues
Sub-Area: Structured Properties, Visibility and Configuration
Applies to: OSS + Cloud
Issue
You delete a structured property in the DataHub UI and create it again. The new property does not show in the right-side sidebar of your datasets, even though the old one did.
Two things cause this:
- A new structured property starts with Show in Asset Sidebar turned off. The sidebar lists only properties that have this setting turned on.
- Deleting the old property removed its values from every asset. The new property is a different entity and has no values yet.
You Might Be Asking
- Why does my recreated structured property not show in the dataset sidebar?
- Does deleting a structured property remove its values from all datasets?
- Why does my new structured property have a different URN than the original?
- Can I recreate a deleted structured property with the same URN?
- How do I add the values back to many datasets at once?
Cause
Deleting a structured property in the DataHub UI permanently deletes it. DataHub then removes its values from every asset that had one. You cannot undo this delete, and recreating the property does not bring the values back.
A recreated property is a new entity. Its URN is urn:li:structuredProperty:<id>. If you set a Qualified Name under Advanced Options when you create it, that name is the id. If you leave it empty, DataHub generates a random id. So a property created without a Qualified Name gets a different URN than the old one, even with the same display name.
In the property's Display Preferences, a new property has Show in Asset Sidebar and Hide when Empty turned off. Hide when Empty appears only after you turn on Show in Asset Sidebar. With Show in Asset Sidebar off, the property never shows in the sidebar, even on assets that have a value. Turning Hide when Empty off does not change that.
Solution
- Turn on the sidebar setting. Go to Govern > Structured Properties and edit the property. Under Display Preferences, turn on Show in Asset Sidebar. You need the Manage Structured Properties privilege. See Set Display Preferences for the Structured Property.
- Choose Hide when Empty. With it off, the property shows in the sidebar of every asset it applies to, with or without a value. With it on, the property shows only on assets that have a value. Also check that Hide Property is off. Hide Property hides the property everywhere.
- Add the values back. The Properties tab of a dataset lists only properties that have a value on it. To add one, click + on the Properties tab, or click + next to the property in the sidebar. You need the Edit Properties privilege on the dataset.
- To add values to many datasets, use a patch with the Python SDK.
set_structured_propertysets the values of that one property and keeps the other structured properties on the dataset.
from datahub.emitter.mce_builder import make_dataset_urn
from datahub.ingestion.graph.client import DataHubGraph, DatahubClientConfig
from datahub.specific.dataset import DatasetPatchBuilder
graph = DataHubGraph(
DatahubClientConfig(server="<your DataHub GMS URL>", token="<your access token>")
)
dataset_urns = [
make_dataset_urn(platform="snowflake", name="db.schema.table_a", env="PROD"),
make_dataset_urn(platform="snowflake", name="db.schema.table_b", env="PROD"),
]
for dataset_urn in dataset_urns:
patch_builder = DatasetPatchBuilder(dataset_urn)
patch_builder.set_structured_property(
"urn:li:structuredProperty:<your property id>", "<your value>"
)
for mcp in patch_builder.build():
graph.emit(mcp)
The patch API is described in Patch. Do not use datahub ingest -c for this. It runs only ingestion recipes with a source block. Be careful with datahub dataset upsert: it replaces all structured property values on the dataset with the ones in your file.
Recreating a property with the same URN
To get a predictable URN, enter a Qualified Name under Advanced Options when you create the property. Enter only the id, for example my.property, not the full URN. DataHub builds urn:li:structuredProperty:my.property from it. The Qualified Name cannot contain spaces, and you cannot change it after you create the property.
In DataHub Cloud v2.2.0 and later and DataHub v1.8.0 and later, you cannot reuse the Qualified Name of a hard-deleted property right away. DataHub rejects the create with an error that starts with:
Structured property Elasticsearch field '<field name>' (from qualifiedName='<qualified name>') already exists in the entity-index mapping.
The old field stays in the search indices until they are rebuilt. On DataHub Cloud, contact DataHub Support to rebuild them. The full steps are in Structured Property Hard Delete Blocks Recreation Due to Persistent Elasticsearch Field Mapping. You can also pick a new Qualified Name. Then update any scripts or transformers that use the old URN.
Avoid this next time
If you might need a property again, soft delete it instead. datahub delete --urn "<property urn>" does a soft delete. A soft delete keeps the property and its values, and you can undo it. See Delete Structured Properties and Handling Stale Structured Property References.
Related Documentation
- Create and Add a DataHub Structured Property
- About DataHub Structured Properties
- Structured Properties API tutorial: Delete Structured Properties
- Patch
Tags: structured-properties, show-in-asset-sidebar, hide-when-empty, property-recreation, dataset-properties, urn, qualified-name, delete-property, re-associate, patch