Implementation:Datahub project Datahub MetadataChangeProposalWrapper Java
| Knowledge Sources | |
|---|---|
| Domains | Metadata_Integration, Event_Serialization |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
Description
MetadataChangeProposalWrapper is a generic, type-safe Java class that simplifies the creation of MetadataChangeProposal events in the DataHub Java SDK. It wraps the core fields needed for a metadata change proposal: entity type, entity URN, change type, aspect, and aspect name. The class provides a step builder pattern that enforces a mandatory construction order (entity type, entity URN, change type, aspect), reducing the chance of creating invalid proposals.
The class attempts to automatically infer the aspect name from the aspect's schema properties via the "Aspect" key in the schema's property map. If inference fails, the aspect name must be explicitly provided through the builder's aspectName() method.
Usage
Used across the DataHub Java SDK and integration modules to construct metadata change proposal events that are subsequently serialized by EventFormatter and emitted to GMS or Kafka. The step builder pattern is the preferred construction method.
Code Reference
Source Location
metadata-integration/java/datahub-event/src/main/java/datahub/event/MetadataChangeProposalWrapper.java
Signature
@Value
@Slf4j
@AllArgsConstructor
public class MetadataChangeProposalWrapper<T extends DataTemplate> {
String entityType;
String entityUrn;
ChangeType changeType;
T aspect;
String aspectName;
public static EntityTypeStepBuilder builder()
public static MetadataChangeProposalWrapper create(
Consumer<EntityTypeStepBuilder> builderConsumer)
}
Step Builder Interfaces:
public interface EntityTypeStepBuilder {
EntityUrnStepBuilder entityType(String entityType);
}
public interface EntityUrnStepBuilder {
ChangeStepBuilder entityUrn(String entityUrn);
ChangeStepBuilder entityUrn(Urn entityUrn);
}
public interface ChangeStepBuilder {
AspectStepBuilder upsert();
}
public interface AspectStepBuilder {
Build aspect(DataTemplate aspect);
}
public interface Build {
MetadataChangeProposalWrapper build();
Build aspectName(String aspectName);
}
Import
import datahub.event.MetadataChangeProposalWrapper;
I/O Contract
Inputs
| Parameter | Type | Description |
|---|---|---|
entityType |
String |
The entity type (e.g., "dataset", "chart")
|
entityUrn |
String or Urn |
The entity URN; validated for correctness on set |
changeType |
ChangeType |
Currently only UPSERT is supported through the builder
|
aspect |
DataTemplate |
The aspect data template to include in the proposal |
aspectName |
String (optional) |
Overrides auto-inferred aspect name |
Outputs
| Return Type | Description |
|---|---|
MetadataChangeProposalWrapper |
Immutable value object containing all fields for a metadata change proposal |
Exceptions:
EventValidationException-- if URN parsing fails or required fields are missing at build time
Usage Examples
// Using the step builder
MetadataChangeProposalWrapper mcpw = MetadataChangeProposalWrapper.builder()
.entityType("dataset")
.entityUrn("urn:li:dataset:(urn:li:dataPlatform:mysql,db.table,PROD)")
.upsert()
.aspect(datasetProperties)
.build();
// Using the consumer-based create method
MetadataChangeProposalWrapper mcpw = MetadataChangeProposalWrapper.create(
b -> b.entityType("dataset")
.entityUrn("urn:li:dataset:(urn:li:dataPlatform:mysql,db.table,PROD)")
.upsert()
.aspect(datasetProperties));
// Direct constructor (all args)
MetadataChangeProposalWrapper mcpw = new MetadataChangeProposalWrapper(
"dataset",
"urn:li:dataset:(urn:li:dataPlatform:mysql,db.table,PROD)",
ChangeType.UPSERT,
datasetProperties,
"datasetProperties");
Related Pages
- Datahub_project_Datahub_MetadataEventFormatter -- Serializes MetadataChangeProposalWrapper to wire format