Skip to main content
Version: Next

Gravitino Type Mapping

This document describes the type mapping between Apache Gravitino and SeaTunnel when using Gravitino as the metadata source. The type conversion is handled by GravitinoTableSchemaConvertor.

Overview

When SeaTunnel reads table schema from Gravitino, the Gravitino column types are automatically converted to corresponding SeaTunnel data types. This mapping enables seamless integration between Gravitino-managed metadata and SeaTunnel's data processing pipeline.

Primitive Type Mapping

Gravitino TypeGravitino JSON RepresentationSeaTunnel TypeSeaTunnel Type KeywordJava TypeNotes
BooleanbooleanBasicType.BOOLEAN_TYPEbooleanjava.lang.Boolean-
BytebyteBasicType.BYTE_TYPEtinyintjava.lang.Byte-
Unsigned Bytebyte unsignedBasicType.BYTE_TYPEtinyintjava.lang.ByteUnsigned flag is ignored
ShortshortBasicType.SHORT_TYPEsmallintjava.lang.Short-
Unsigned Shortshort unsignedBasicType.SHORT_TYPEsmallintjava.lang.ShortUnsigned flag is ignored
IntegerintegerBasicType.INT_TYPEintjava.lang.Integer-
Unsigned Integerinteger unsignedBasicType.INT_TYPEintjava.lang.IntegerUnsigned flag is ignored
LonglongBasicType.LONG_TYPEbigintjava.lang.Long-
Unsigned Longlong unsignedBasicType.LONG_TYPEbigintjava.lang.LongUnsigned flag is ignored
FloatfloatBasicType.FLOAT_TYPEfloatjava.lang.FloatSingle-precision floating point
DoubledoubleBasicType.DOUBLE_TYPEdoublejava.lang.DoubleDouble-precision floating point
Decimaldecimal(p, s)DecimalType(p, s)"decimal(p,s)"java.math.BigDecimalPrecision: 1-38, Scale: 0-precision
StringstringBasicType.STRING_TYPEstringjava.lang.StringVariable-length string
FixedCharchar(l)BasicType.STRING_TYPEstringjava.lang.StringFixed-length string, length stored in columnLength
VarCharvarchar(l)BasicType.STRING_TYPEstringjava.lang.StringVariable-length string, max length stored in columnLength
UUIDuuidBasicType.STRING_TYPEstringjava.lang.StringUniversally unique identifier
DatedateLocalTimeType.LOCAL_DATE_TYPEdatejava.time.LocalDateDate without time
TimetimeLocalTimeType.LOCAL_TIME_TYPEtimejava.time.LocalTimeTime without date
Timestamptimestamp(p)LocalTimeType.LOCAL_DATE_TIME_TYPEtimestampjava.time.LocalDateTimeTimestamp without timezone, p=0-12
TimestampTztimestamp_tz(p)LocalTimeType.OFFSET_DATE_TIME_TYPEtimestamp_tzjava.time.OffsetDateTimeTimestamp with timezone, p=0-12
BinarybinaryPrimitiveByteArrayType.INSTANCEbytesbyte[]Variable-length binary
Fixedfixed(l)PrimitiveByteArrayType.INSTANCEbytesbyte[]Fixed-length binary
IntervalYearinterval_yearBasicType.STRING_TYPEstringjava.lang.StringYear-month interval
IntervalDayinterval_dayBasicType.STRING_TYPEstringjava.lang.StringDay-time interval

Complex Type Mapping

Gravitino TypeGravitino JSON RepresentationSeaTunnel TypeSeaTunnel Type KeywordNotes
List{"type": "list", "elementType": type, "containsNull": boolean}ArrayType"array<T>"T is the element type
Map{"type": "map", "keyType": type, "valueType": type, "valueContainsNull": boolean}MapType"map<K,V>"K is key type, V is value type
Struct{"type": "struct", "fields": [...]}SeaTunnelRowType{field1=type1, field2=type2, ...}Nested row type
External{"type": "external", "catalogString": "user-defined"}BasicType.STRING_TYPEstringFor unsupported types like PostgreSQL jsonb
Union{"type": "union", "types": [...]}Not Supported-Throws conversion error

Type Parameter Extraction

The converter extracts type parameters for column metadata:

TypeParameterExtracted AsNotes
decimal(p, s)precision, scalecolumnLength=precision, scale=scaleBoth values stored
varchar(l)lengthcolumnLength=lengthMaximum string length
char(l)lengthcolumnLength=lengthFixed string length
fixed(l)lengthcolumnLength=lengthFixed binary length
timestamp(p)precisioncolumnLength=precisionFractional seconds precision (0-12)
timestamp_tz(p)precisioncolumnLength=precisionFractional seconds precision (0-12)

Index and Constraint Mapping

Gravitino indexes are mapped to SeaTunnel constraints:

Gravitino Index TypeSeaTunnel Constraint TypeNotes
PRIMARY_KEYPrimaryKeyExtracts column names from fieldNames array
UNIQUE_KEYConstraintKey.UNIQUE_KEYColumn sort order defaults to ASC

Notes and Limitations

  1. Case Insensitivity: Type matching is case-insensitive. BOOLEAN, boolean, and Boolean are treated the same.

  2. Unsigned Types: The unsigned modifier for numeric types is recognized but does not affect the converted SeaTunnel type. SeaTunnel uses signed types internally.

  3. External Types: When Gravitino encounters a type it cannot parse (such as PostgreSQL's jsonb), it represents it as an external type. SeaTunnel converts these to string type.

  4. Union Types: Gravitino's union type is not currently supported and will throw a conversion error.

  5. Nullable: The nullable attribute in Gravitino column definitions is preserved in the SeaTunnel Column metadata.

  6. Decimal Parameters: The decimal type requires both precision and scale parameters. Decimal values without parameters or with invalid format will throw an error.