Implementation:Datahub project Datahub SchemaTronDataHubType
| 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
UnionTypewith optional nested types as aStringArray. - ArrayType -- Creates an
ArrayTypewith optional nested type as aStringArray. - MapType -- Creates a
MapTypewith"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 notUnionType,ArrayType, orMapType
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
- Datahub_project_Datahub_FieldPath_Schematron -- Uses DataHubType as a parent type for field path elements
- Datahub_project_Datahub_SchemaTron_CLI -- CLI that uses the schema converter which depends on DataHubType