Area: Ingestion
Sub-Area: Entity Management
Applies to: OSS + Cloud
Issue
You try to soft delete a domain by writing the status aspect with removed=true, for example from a custom ingestion source. On open source DataHub the write fails with this error:
Unknown aspect status for entity domain
You Might Be Asking
- Does the domain entity support soft deletion?
- How can I delete a domain programmatically?
- Why does
datahub delete --urnfail for a domain? - How can I mark a domain as retired without deleting it?
Cause
In open source DataHub, the domain entity has no status aspect. Its aspects include domainProperties, institutionalMemory, ownership, structuredProperties, forms, testResults, displayProperties and assetSettings. A soft delete is a write of the status aspect with removed=true, so it fails on OSS with the error above.
On DataHub Cloud v0.3.16 and later, domains do have a status aspect, so a soft delete of a domain is accepted.
The datahub delete command soft deletes by default. Without --hard, it writes status and hits the same error on OSS.
Solution
Hard delete a domain on OSS
A hard delete permanently removes the domain's rows from the database. You can't undo it. Use one of these:
-
CLI. Add
--hard. Without--force, the CLI asks you to confirm, because hard deletes can slow down your instance while they run.
datahub delete --urn "urn:li:domain:your-domain-id" --hard
-
Python SDK. Use a
DataHubGraphclient. Callhard_delete_entity(urn), ordelete_entity(urn, hard=True).delete_entitysoft deletes unless you passhard=True. -
GraphQL. The
deleteDomain(urn: String!): Booleanmutation ("Delete a Domain") exists. DataHub rejects the deletion of a domain that still has child domains.
mutation {
deleteDomain(urn: "urn:li:domain:your-domain-id")
}
Mark a domain as retired without deleting it
Domains support the deprecation aspect on OSS v1.7.0 and later, and on DataHub Cloud v2.1.0 and later. On earlier versions, the domain entity has no deprecation aspect. A write of that aspect fails with the error "Unknown aspect deprecation for entity domain".
If your version supports it, set the aspect with the updateDeprecation GraphQL mutation. Its input takes urn, deprecated, and optionally decommissionTime and note. You need the "Edit Deprecation" privilege or the "Edit Entity" privilege. A policy that is limited to the Domain type can't select "Edit Deprecation". For such a policy, use "Edit Entity".
From Python, build a MetadataChangeProposalWrapper(entityUrn=..., aspect=DeprecationClass(...)) and call emitter.emit(mcpw) or emitter.emit_mcp(mcpw). emit_mcp takes a single MCP object. It does not accept entity_urn, aspect_name or aspect keyword arguments.
On Cloud
On Cloud v0.3.16 and later, you can soft delete a domain. Run datahub delete --urn "<urn>" without --hard. You can also write status with removed=true. To restore the domain, run datahub delete undo-by-filter --urn "<urn>". Use --hard only when you want a permanent hard delete.
Caution: If you omit --urn, the command restores every soft deleted entity that it finds. It does not restore only the domain.