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 PatchTransformer

From Leeroopedia


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

Overview

Description

PatchTransformer is a strategy interface for transforming patch MetadataChangeProposal (MCP) objects based on server capabilities and configuration. It allows adaptation of patch operations to work with servers that have different feature support levels.

Transformers are applied at emission time in EntityClient.upsert(), after all patch operations have been accumulated but before they are sent to the server. Each transformed patch is wrapped in a TransformResult which includes an optional retry function for optimistic locking with retry on version conflicts.

Key use cases:

  • Transforming incremental patches to full aspect replacements for servers with broken or missing patch implementations
  • Adding retry functions for MCPs that use read-modify-write patterns (enabling optimistic locking)
  • Passing patches through unchanged for compatible servers

Usage

Implementations of this interface are registered with the entity client and invoked automatically during upsert operations. The primary implementation is VersionAwarePatchTransformer, which handles version-specific server compatibility issues.

Code Reference

Source Location

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

Signature

public interface PatchTransformer {

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

Import

import datahub.client.v2.patch.PatchTransformer;

I/O Contract

Inputs

Parameter Type Description
patches List<MetadataChangeProposal> The original patch MCPs to transform
serverConfig ServerConfig (nullable) Server configuration; null if not fetched or fetch failed

Outputs

Return Type Description
List<TransformResult> List of results, each containing a (potentially transformed) MCP and an optional retry function for version conflict handling

Transformer Behaviors:

Scenario Behavior
Server supports patches Returns patches unchanged with null retry function
Incompatible server Transforms patches to full aspect replacements
Read-modify-write needed Adds retry functions for optimistic locking
Unsupported patches Filters out unsupported patches

Exceptions:

  • Exception - if transformation fails (e.g., aspect fetch failure during read-modify-write)

Usage Examples

// PatchTransformer is used internally by EntityClient during upsert.
// Direct usage is typically not needed, but for custom implementations:

public class CustomPatchTransformer implements PatchTransformer {
    @Override
    @Nonnull
    public List<TransformResult> transform(
            @Nonnull List<MetadataChangeProposal> patches,
            @Nullable ServerConfig serverConfig) throws Exception {

        List<TransformResult> results = new ArrayList<>();
        for (MetadataChangeProposal patch : patches) {
            // Pass through with no retry function
            results.add(new TransformResult(patch, null));
        }
        return results;
    }
}

Related Pages

Page Connections

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