Area: API Issues
Sub-Area: Python SDK — Dataset Entity Construction
Issue
When creating a logical model programmatically using the DataHub Python SDK, omitting the display_name parameter causes the entity's full technical name (including any dotted namespace prefix) to be used as the visible card title in the UI. For example, a dataset created with name="my_namespace.my_table" will display the entire string as the title, and because the browse folder is also derived from that dotted path, the namespace segment appears to repeat visually. When the same logical model is created through the DataHub UI, a dedicated "Display Name" field is presented, which produces the correct, human-readable label. The SDK equivalent of that field is non-obvious, leading users to believe there is no programmatic way to set it.
You Might Be Asking
- Why does the namespace appear twice in the entity card title when I create a logical model in code?
- How do I set a display name for a logical model using the DataHub Python SDK?
- What is the SDK equivalent of the "Display Name" field shown in the DataHub UI?
- Why doesn't setting
descriptionalone populate thedatasetPropertiesaspect?
Solution
Pass the display_name argument to the Dataset constructor. This parameter maps directly to datasetProperties.name — the same field the UI's "Display Name" box writes — and becomes the label shown on the entity card.
-
Add
display_nameto theDatasetconstructor:from datahub.sdk import DataHubClient, Dataset client = DataHubClient.from_env() dataset = Dataset( platform="logical", name="<your_namespace>.<your_table_name>", # Used to build the URN — keep it unique display_name="<your_table_name>", # Human-readable label shown in the UI description="<Your logical model description>", schema=[ # your schema fields here ], ) client.entities.upsert(dataset) -
Alternatively, set the display name after construction using the setter method:
dataset = Dataset( platform="logical", name="<your_namespace>.<your_table_name>", description="<Your logical model description>", schema=[ # your schema fields here ], ) dataset.set_display_name("<your_table_name>") client.entities.upsert(dataset) -
Re-run the upsert against an already-created entity to fix it in place. Because the URN is determined by
platformandname— not bydisplay_name— addingdisplay_nameand re-upserting will update the existing entity without creating a duplicate.
Additional Notes
Why the namespace appears to repeat: DataHub derives both the card title and the browse-folder path from the dotted name value when no datasetProperties aspect exists. The folder is <your_namespace> and the fallback title is the full string <your_namespace>.<your_table_name>, making the namespace appear twice in the UI. Setting display_name populates the datasetProperties aspect and resolves this.
Why description alone does not create datasetProperties: DataHub maintains two separate properties aspects for datasets:
-
datasetProperties— the source-of-truth aspect written by ingestion connectors. Thedisplay_namefield maps here. -
editableDatasetProperties— holds edits made by users in the UI. When the SDK client writes adescriptionoutside of a formal ingestion pipeline, it targets this editable aspect rather thandatasetProperties. This is intentional: it ensures that running ingestion again never silently overwrites something a user typed in the UI.
Because of this separation, setting only description does not create the datasetProperties aspect, so no datasetProperties.name value is recorded, and the card title falls back to the URN's technical name. Adding display_name is what causes datasetProperties to be written.
SDK version note: The display_name parameter and set_display_name() method are available in the DataHub Python SDK v2 client (datahub.sdk). Ensure your acryl-datahub package is up to date.
Related Documentation
- Python SDK v2 — Dataset Entity:
display_nameproperty - DataHub Metadata Model — Understanding Aspects
- Dataset Entity — Full Aspect List
Tags: python-sdk, logical-model, display-name, dataset, datasetProperties, aspects, upsert, sdk-v2, ingestion, metadata-model