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 HasSubTypes Mixin

From Leeroopedia


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

Overview

Description

HasSubTypes is a mixin interface in the DataHub Java SDK V2 that provides subtype assignment operations for entities. SubTypes allow specializing a generic entity type (e.g., making a Dataset also be a View or LookerExplore).

Unlike the patch-based mixins (such as HasOwners or HasGlossaryTerms), this interface exclusively uses full aspect replacement via MetadataChangeProposalWrapper. Setting subtypes always replaces any existing subtypes entirely.

The interface uses the self-bounded generic pattern (T extends Entity & HasSubTypes<T>) for fluent API chaining.

Usage

Entity classes implement this interface to gain subtype assignment capabilities. The setSubTypes() method accepts either varargs strings or a List<String> of subtype names, and creates a pending MCP for full aspect replacement at save time.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/v2/entity/HasSubTypes.java

Signature

public interface HasSubTypes<T extends Entity & HasSubTypes<T>> {

    @Nonnull
    default T setSubTypes(@Nonnull String... typeNames)

    @Nonnull
    default T setSubTypes(@Nonnull List<String> typeNames)
}

Import

import datahub.client.v2.entity.HasSubTypes;

I/O Contract

Inputs

Method Parameter Type Description
setSubTypes typeNames String... Varargs subtype names to set
setSubTypes typeNames List<String> List of subtype names to set

Outputs

Method Return Type Description
setSubTypes T The entity itself for fluent chaining

Usage Examples

Dataset dataset = Dataset.builder()
    .platform("snowflake")
    .name("my_table")
    .build();

// Set subtypes using varargs
dataset.setSubTypes("view", "materialized");

// Set subtypes using a list
dataset.setSubTypes(Arrays.asList("view", "materialized"));

// Fluent chaining
Dataset result = dataset
    .setSubTypes("view")
    .setContainer("urn:li:container:myContainer");

Related Pages

Page Connections

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