Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub VersionAwarePatchTransformer

From Leeroopedia


Knowledge Sources
Domains Java_SDK, Metadata_Management
Last Updated 2026-02-10 00:00 GMT

Overview

Description

VersionAwarePatchTransformer is the primary implementation of the PatchTransformer interface. It transforms patch MetadataChangeProposal (MCP) objects based on server version compatibility, handling known version-specific issues with patches on DataHub servers.

The transformer addresses two categories of compatibility:

  • Always-transformed aspects: mlModelProperties patches are not supported on any current server version and are always transformed to full aspect replacements with optimistic locking retry functions.
  • Version-gated aspects: Patches for editableContainerProperties, editableDatasetProperties, and editableMLModelGroupProperties are transformed only for DataHub Core servers at version <= v1.3.0.

Version thresholds:

Aspect DataHub Core DataHub Cloud
mlModelProperties Always transform Always transform
editableContainerProperties > v1.3.0 TBD
editableDatasetProperties > v1.3.0 TBD
editableMLModelGroupProperties > v1.3.0 TBD

The class uses Lombok @RequiredArgsConstructor and @Slf4j annotations.

Usage

This transformer is instantiated with an EntityClient reference (needed for read-modify-write operations) and is invoked automatically during entity upsert operations. When server config is unavailable, patches are passed through unchanged with a warning.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/v2/patch/VersionAwarePatchTransformer.java

Signature

@Slf4j
@RequiredArgsConstructor
public class VersionAwarePatchTransformer implements PatchTransformer {

    @Nonnull
    private final EntityClient entityClient;

    @Override
    @Nonnull
    public List<TransformResult> transform(
        @Nonnull List<MetadataChangeProposal> patches,
        @Nullable ServerConfig serverConfig) throws Exception

    private boolean needsPatchTransformation(@Nonnull ServerConfig serverConfig)
}

Import

import datahub.client.v2.patch.VersionAwarePatchTransformer;

I/O Contract

Inputs

Parameter Type Description
constructor entityClient EntityClient Client used for read-modify-write during transformation
transform patches List<MetadataChangeProposal> Original patch MCPs to transform
transform serverConfig ServerConfig (nullable) Server configuration for version checking

Outputs

Method Return Type Description
transform List<TransformResult> Transformed MCPs with optional retry functions

Transformation behavior by aspect:

Aspect Name Server Config Null Server Compatible Server Incompatible
mlModelProperties Pass-through (no retry) Full replacement + retry Full replacement + retry
editableContainerProperties Pass-through Pass-through Full replacement (no retry)
editableDatasetProperties Pass-through Pass-through Full replacement (no retry)
editableMLModelGroupProperties Pass-through Pass-through Full replacement (no retry)
Other aspects Pass-through Pass-through Pass-through

Exceptions:

  • Exception - if transformation fails (e.g., aspect fetch failure)
  • RuntimeException - wrapping retry failures for mlModelProperties

Usage Examples

// VersionAwarePatchTransformer is typically used internally by EntityClient.
// It is instantiated with the EntityClient reference:

EntityClient entityClient = new EntityClient(config);
VersionAwarePatchTransformer transformer =
    new VersionAwarePatchTransformer(entityClient);

// Transform patches based on server capabilities
List<MetadataChangeProposal> patches = collectPatches();
ServerConfig serverConfig = entityClient.getServerConfig();
List<TransformResult> results = transformer.transform(patches, serverConfig);

// Each result contains the MCP and optional retry function
for (TransformResult result : results) {
    MetadataChangeProposal mcp = result.getMcp();
    // result.getRetryFn() may be non-null for optimistic locking
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment