Area: Best Practices
Sub-Area: Description Management & Dual-Aspect Architecture
Applies to: OSS + Cloud
Issue
You ingest descriptions from a source system such as Snowflake. Some tables and columns also have descriptions that people edited in DataHub. DataHub shows the edited description, so the source description stays hidden. You now want DataHub to show the source descriptions again for many datasets. You don't want to lose column tags or glossary terms, and you don't want to re-ingest.
You Might Be Asking
- Why doesn't the description from my Snowflake ingestion show up after I re-run ingestion?
- How do I make DataHub show the ingested description instead of the edited one?
- How do I remove edited descriptions across many datasets at once?
- Will removing edited descriptions also delete my column tags and glossary terms?
- I set the edited descriptions to an empty string. Why are the descriptions blank now?
- Do I need to re-ingest after I remove the edits?
Cause
DataHub stores two descriptions for each table and column:
- Ingestion writes the source description to
datasetProperties(tables) andschemaMetadata(columns). - An edit in the UI or the API goes to
editableDatasetProperties(tables) andeditableSchemaMetadata(columns).
A non-empty edited description shows instead of the ingested one. Ingestion does not overwrite it. Re-running ingestion does not change which one shows.
An edited description that is an empty string still counts as an edit in these cases:
- Columns, in open source DataHub and in all DataHub Cloud versions. The column shows blank.
- Tables, in DataHub Cloud v2.4.0 and later. The table shows blank. In open source DataHub and in DataHub Cloud before v2.4.0, an empty table description falls back to the ingested one.
In DataHub Cloud v2.4.0 and later, setting an edited description to an empty string also deletes the AI-generated descriptions of that table or column.
To show the ingested description, remove the description field from the editable aspect. Don't set it to an empty string. After the field is gone, DataHub shows the ingested description right away. You don't need to re-ingest.
Don't delete the whole editable aspect:
-
editableSchemaMetadataalso holds the tags and glossary terms that people added to columns in DataHub. Deleting it removes them. -
editableDatasetPropertiesalso holds a display name set in DataHub. Deleting it removes the name.
Solution
Use the OpenAPI v3 PATCH endpoint with a JSON Patch remove operation. It removes only the description field and keeps everything else in the aspect. See Generic Patching in the OpenAPI guide.
- Table:
PATCH /openapi/v3/entity/dataset/<url-encoded urn>/editableDatasetPropertieswith the body{"patch": [{"op": "remove", "path": "/description"}]}. - Column:
PATCH /openapi/v3/entity/dataset/<url-encoded urn>/editableSchemaMetadatawith one operation per column, for example{"op": "remove", "path": "/editableSchemaFieldInfo/<fieldPath>/description"}. DataHub finds the column by itsfieldPath. In the path, write~as~0and/as~1.
A remove on a field that does not exist fails the whole request. Only remove descriptions that are there.
Step 1: Get a token and your URN list
- Create a personal access token in Settings > Access Tokens > Generate Personal Access Token. See Personal Access Tokens.
- List the dataset URNs you want to process.
Step 2: Run the script
The script below reads each dataset. It plans a removal only where the edited description exists and the ingested description is not empty, so no table or column ends up blank. It reports the rest as skipped. It matches columns by exact fieldPath.
It runs as a dry run by default and makes only GET requests. With --apply, it writes a backup of every aspect it will change to a local JSON file, and then sends the PATCH requests.
Set DATAHUB_URL to the URL you open DataHub at. The OpenAPI endpoints are available there under /openapi.
"""
clear_editable_descriptions.py
Removes user-edited descriptions so DataHub shows the ingested ones.
Keeps column tags, glossary terms and display names.
python clear_editable_descriptions.py # dry run, no writes
python clear_editable_descriptions.py --apply --limit 5 # write the first 5 URNs
python clear_editable_descriptions.py --apply # write all URNs
Requires: pip install requests
"""
import argparse
import json
from datetime import datetime, timezone
from urllib.parse import quote
import requests
DATAHUB_URL = "https://<your-instance>.acryl.io"
ACCESS_TOKEN = "<your-personal-access-token>"
URNS = [
"urn:li:dataset:(urn:li:dataPlatform:snowflake,<database>.<schema>.<table>,PROD)",
]
HEADERS = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
def aspect_url(urn, aspect):
return f"{DATAHUB_URL}/openapi/v3/entity/dataset/{quote(urn, safe='')}/{aspect}"
def get_aspect(urn, aspect):
resp = requests.get(aspect_url(urn, aspect), headers=HEADERS, timeout=60)
if resp.status_code == 404:
return None
resp.raise_for_status()
return resp.json()["value"]
def pointer(token):
# JSON Pointer escaping for a fieldPath used in a patch path
return token.replace("~", "~0").replace("/", "~1")
def plan_dataset(urn):
"""Return ({aspect: (current_value, patch_ops)}, report) using GET requests only."""
plan = {}
report = []
edited = get_aspect(urn, "editableDatasetProperties")
if edited and "description" in edited:
ingested = get_aspect(urn, "datasetProperties") or {}
if (ingested.get("description") or "").strip():
plan["editableDatasetProperties"] = (
edited,
[{"op": "remove", "path": "/description"}],
)
report.append({"target": "table", "remove": edited["description"]})
else:
report.append({"target": "table", "skipped": "no ingested description"})
edited_cols = get_aspect(urn, "editableSchemaMetadata")
if edited_cols:
schema = get_aspect(urn, "schemaMetadata") or {}
ingested_cols = {
f["fieldPath"]: (f.get("description") or "").strip()
for f in schema.get("fields", [])
}
ops = []
for info in edited_cols.get("editableSchemaFieldInfo", []):
if "description" not in info:
continue
path = info["fieldPath"]
if ingested_cols.get(path):
ops.append(
{
"op": "remove",
"path": f"/editableSchemaFieldInfo/{pointer(path)}/description",
}
)
report.append({"target": path, "remove": info["description"]})
else:
report.append({"target": path, "skipped": "no ingested description"})
if ops:
plan["editableSchemaMetadata"] = (edited_cols, ops)
return plan, report
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--apply", action="store_true", help="write changes (default: dry run)")
parser.add_argument("--limit", type=int, default=None, help="process only the first N URNs")
args = parser.parse_args()
urns = URNS[: args.limit] if args.limit else URNS
plans = []
for urn in urns:
plan, report = plan_dataset(urn)
plans.append((urn, plan))
print(json.dumps({"urn": urn, "changes": report}, indent=2))
if not args.apply:
print("Dry run: nothing was written. Pass --apply to write.")
return
stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
backup_file = f"description_backup_{stamp}.json"
backup = [
{"urn": urn, "aspect": aspect, "value": current}
for urn, plan in plans
for aspect, (current, _ops) in plan.items()
]
with open(backup_file, "w") as f:
json.dump(backup, f, indent=2)
print(f"Backup written to {backup_file}")
for urn, plan in plans:
for aspect, (_current, ops) in plan.items():
resp = requests.patch(
aspect_url(urn, aspect), headers=HEADERS, json={"patch": ops}, timeout=60
)
resp.raise_for_status()
print(f"Removed {len(ops)} description(s) from {aspect} on {urn}")
if __name__ == "__main__":
main()
Step 3: Run it in stages
- Install the dependency:
pip install requests. - Set
DATAHUB_URL,ACCESS_TOKENandURNSin the script. - Run a dry run and read the report:
python clear_editable_descriptions.py. Check that tables and columns you expected to change showremove, notskipped. - Apply to a few datasets first:
python clear_editable_descriptions.py --apply --limit 5. Check them in the UI. - Apply to the rest:
python clear_editable_descriptions.py --apply.
The ingested descriptions show in the UI right away. You don't need to re-ingest.
Restoring from the backup
The backup file holds the full aspect value for each changed aspect. To restore one, POST it to the same aspect URL with ?createIfNotExists=false and the body {"value": <saved value>}. Without createIfNotExists=false, DataHub rejects the write with Cannot perform CREATE since the aspect already exists. A POST replaces the whole aspect, so it also undoes tag, term or description changes made to that aspect after the backup.
Related Documentation
- DataHub OpenAPI Guide: Generic Patching
- Personal Access Tokens
- Description API tutorial
- Emitting Patch Updates to DataHub
- Snowflake Ingestion Source
- Displaying Both Ingested and Manually Edited Descriptions Using Structured Properties
Tags: descriptions, editable-aspects, snowflake, bulk-operations, schema-metadata, ingestion, user-curation, openapi, json-patch, python-script, dry-run