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

From Leeroopedia


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

Overview

Description

HasContainer is a mixin interface in the DataHub Java SDK V2 that provides container hierarchy operations for entities supporting parent container assignment. Entities implementing this interface can be placed inside a parent container for hierarchical organization (e.g., datasets within a database, charts within a dashboard).

The interface uses a self-bounded generic pattern (T extends Entity & HasContainer<T>) to enable fluent API chaining where each method returns the concrete entity type.

Usage

Entity classes such as Dataset implement this interface to gain container management methods. Callers use setContainer() to assign a parent container by URN (string or Urn object), and clearContainer() to remove the assignment. All methods return the entity itself for fluent method chaining.

Code Reference

Source Location

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

Signature

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

    @Nonnull
    default T setContainer(@Nullable String containerUrn)

    @Nonnull
    default T setContainer(@Nonnull Urn containerUrn)

    @Nonnull
    default T clearContainer()
}

Import

import datahub.client.v2.entity.HasContainer;

I/O Contract

Inputs

Method Parameter Type Description
setContainer containerUrn String (nullable) URN string of the parent container; null clears the container
setContainer containerUrn Urn URN object of the parent container

Outputs

Method Return Type Description
setContainer T The entity itself for fluent chaining
clearContainer T The entity itself for fluent chaining

Exceptions:

  • InvalidUrnException - thrown if the string URN cannot be parsed

Usage Examples

// Assign a dataset to a parent container
Dataset dataset = Dataset.builder()
    .platform("snowflake")
    .name("my_table")
    .build();

dataset.setContainer("urn:li:container:(urn:li:dataPlatform:snowflake,mydb,PROD)");

// Clear the container assignment
dataset.clearContainer();

// Fluent chaining with Urn object
Urn containerUrn = Urn.createFromString("urn:li:container:myContainer");
dataset.setContainer(containerUrn);

Related Pages

Page Connections

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