Area: Ingestion
Sub-Area: Structured Properties
Applies to: OSS + Cloud
Issue
You tried to ingest structured properties by adding a structured_properties block to an ingestion recipe, or by building the aspect in Python with plain dicts. The recipe fails validation, or the values never appear on your assets.
You Might Be Asking
- Why does my recipe fail when I add
structured_properties? - Why aren't my structured properties showing up on my assets?
- What is the correct way to define and assign structured properties?
- How do I set a structured property value from Python?
- Can I use BOOLEAN as a property type?
Cause
Recipes have no structured_properties key. A recipe accepts only these top-level keys: source, sink, transformers, flags, reporting, run_id, datahub_api, pipeline_name, failure_log and recording. Any other top-level key fails validation.
Structured properties work in two separate steps:
- You define the property (name, type, allowed values). The value type belongs to the definition. You do not set it on each value.
- You assign values to assets.
Property types are string, number, urn, rich_text and date in the CLI YAML. In GraphQL they are the URNs urn:li:dataType:datahub.string, .number, .urn, .rich_text and .date. There is no boolean type. Dates use the format YYYY-MM-DD.
In the Python SDK, a value assignment is a StructuredPropertyValueAssignmentClass object with propertyUrn and a list named values. The field is values, not value.
Solution
1. Define the property with the CLI
Write a definition YAML file. The supported fields are id, urn, qualified_name, type, version, value_entity_types, description, display_name, entity_types, cardinality, allowed_values, type_qualifier, immutable and structured_property_settings. Use lowercase type names. Each allowed_values entry has value and description.
- id: io.mycompany.property_name
qualified_name: io.mycompany.property_name
type: string
display_name: Property Name
description: Example property
The YAML needs id (or urn). An entry with only qualified_name fails with "id must be present if urn is not". If you set both id and qualified_name, they must match.
Add entity_types and cardinality as your use case needs. In the YAML, entity_types: [dataset] is valid. See the structured properties tutorial for full examples.
Load the file:
datahub properties upsert -f <file>
Check what exists with datahub properties list or datahub properties get --urn <urn>.
2. Assign values with the CLI
In the dataset YAML, add a structured_properties map of property name to value, then load it:
datahub dataset upsert -f <file> --dry-run
datahub dataset upsert -f <file>
A dry run (-n) does not confirm that the write will succeed. It connects to DataHub, reads the YAML and checks that the structured properties and glossary terms it references exist. It builds the change but does not send it. The dry run can print "Update succeeded" and the real run can still fail when it sends the change. The second command writes. The tutorial shows the full file layout.
3. Or assign values with GraphQL
mutation {
upsertStructuredProperties(input: {
assetUrn: "<asset urn>",
structuredPropertyInputParams: [{
structuredPropertyUrn: "urn:li:structuredProperty:io.mycompany.property_name",
values: [{stringValue: "property_value"}]
}]
}) {
properties { structuredProperty { urn } }
}
}
Use numberValue for number properties. Remove values with removeStructuredProperties(input: {assetUrn, structuredPropertyUrns}). On DataHub Cloud, you can try this in GraphiQL. See Cloud GraphQL getting started.
4. Or assign values from Python
Build StructuredPropertiesClass(properties=[StructuredPropertyValueAssignmentClass(propertyUrn=..., values=...)]). Building the aspect sends nothing. You must emit it.
DataHubRestEmitter.emit_mcp takes one MetadataChangeProposalWrapper (or MetadataChangeProposal), plus the optional async_flag, emit_mode and wait_timeout. It does not accept entity_urn, aspect_name or aspect keywords. Those raise a TypeError. Put the aspect inside the proposal wrapper and pass that single object to emit_mcp.
For one property on one asset, the GraphQL mutation above or HasStructuredPropertiesPatch.set_structured_property(key, value, attribution_source=None) adds or updates one property. Both are simpler than writing the whole aspect.
5. If values still don't show up
The server rejects a write with an error when:
- The property definition is soft deleted ("Cannot apply a soft deleted Structured Property value").
- A
SINGLEproperty gets more than one value. - A value has the wrong type, such as a date not in
YYYY-MM-DD. - A value is not in the property's allowed values.
- The property is immutable and you try to change it ("Cannot mutate an immutable property").
- A string value is longer than 32766 UTF-8 bytes (HTTP 422 by default).
If you assign a property that doesn't exist, the write drops that assignment with a server-side warning by default. The write succeeds if at least one valid assignment remains. Create the property first. On self-hosted DataHub you can make this strict with STRUCTURED_PROPERTIES_DROP_MISSING_PROPERTY_VALUES_WITH_WARNING. On Cloud this is a server setting, so contact DataHub Support.
You also need permission to manage structured properties to create them, and permission to edit properties on the asset to assign values.
6. Versions
The previous version of this article named a specific fix version. The release notes do not support it, and no migration guide exists. Structured property fixes appear in the Cloud v0.3.10 and v0.3.11 release notes. If you hit a defect, upgrade to the latest release.