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 SchemaTronDataHubType

From Leeroopedia
Revision as of 14:44, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Datahub_project_Datahub_SchemaTronDataHubType.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Schema_Conversion, Type_System
Last Updated 2026-02-10 00:00 GMT

Overview

Description

DataHubType is a model class in the SchemaTron library that represents a DataHub schema field type with an optional nested type. It wraps a Java Class reference (representing the DataHub type class) and a String nested type, and provides a method to convert them into a SchemaFieldDataType.

The asSchemaFieldType() method handles three compound DataHub types:

  • UnionType -- Creates a UnionType with optional nested types as a StringArray.
  • ArrayType -- Creates an ArrayType with optional nested type as a StringArray.
  • MapType -- Creates a MapType with "string" as the key type and the nested type as the value type.

Any other type class results in an IllegalArgumentException.

Usage

Used internally by the SchemaTron schema converters (particularly the Avro schema converter) to represent intermediate type information before it is converted to DataHub's SchemaFieldDataType model.

Code Reference

Source Location

metadata-integration/java/datahub-schematron/lib/src/main/java/io/datahubproject/schematron/models/DataHubType.java

Signature

@Data
public class DataHubType {

    private Class type;
    private String nestedType;

    public DataHubType(Class type, String nestedType)

    public SchemaFieldDataType asSchemaFieldType()
}

Import

import io.datahubproject.schematron.models.DataHubType;

I/O Contract

Inputs

Parameter Type Description
type Class The DataHub type class: UnionType.class, ArrayType.class, or MapType.class
nestedType String (nullable) The nested type name (e.g., "string", "com.example.MyRecord")

Outputs

Method Return Type Description
asSchemaFieldType() SchemaFieldDataType The DataHub schema field data type with the appropriate union, array, or map configuration

Exceptions:

  • IllegalArgumentException -- if the type class is not UnionType, ArrayType, or MapType

Usage Examples

// Union type with nested type
DataHubType unionType = new DataHubType(UnionType.class, "string");
SchemaFieldDataType fieldType = unionType.asSchemaFieldType();

// Array type without nested type
DataHubType arrayType = new DataHubType(ArrayType.class, null);
SchemaFieldDataType fieldType = arrayType.asSchemaFieldType();

// Map type with value type
DataHubType mapType = new DataHubType(MapType.class, "int");
SchemaFieldDataType fieldType = mapType.asSchemaFieldType();
// Results in MapType with keyType="string", valueType="int"

Related Pages

Page Connections

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