gravitino.api.types.types.Types

class gravitino.api.types.types.Types

Bases: object

The helper class for Type. It contains all built-in types and provides utility methods.

__init__()

Methods

__init__()

allow_auto_increment(data_type)

Checks if the given data type is allowed to be an auto-increment column.

class BinaryType

Bases: PrimitiveType

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class BooleanType

Bases: PrimitiveType

The boolean type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class ByteType(signed: bool = True)

Bases: IntegralType

The byte type in Gravitino.

name() Name

Returns the generic name of the type.

signed() bool

Returns True if the integer type is signed, False otherwise.

simple_string() str

Returns a readable string representation of the type.

class DateType

Bases: DateTimeType

The date time type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class DecimalType(precision: int, scale: int)

Bases: FractionType

The decimal type in Gravitino.

static check_precision_scale(precision: int, scale: int)

Ensures the precision and scale values are within valid range.

Args:

precision: The precision of the decimal. scale: The scale of the decimal.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class DoubleType

Bases: FractionType

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class ExternalType(catalog_string: str)

Bases: Type

Represents a type that is defined in an external catalog.

name() Name

Returns the generic name of the type.

classmethod of(catalog_string: str) ExternalType

Creates a new ExternalType with the given catalog string.

Args:

catalog_string The string representation of this type in the catalog.

Returns:

A new ExternalType instance.

simple_string() str

Returns a readable string representation of the type.

class FixedCharType(length: int)

Bases: PrimitiveType

The fixed char type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class FixedType(length: int)

Bases: PrimitiveType

Fixed-length byte array type, if you want to use variable-length byte array, use BinaryType instead.

name() Name

Returns the generic name of the type.

classmethod of(length: int) FixedType
Args:

length: The length of the fixed type.

Returns:

A FixedType instance with the given length.

simple_string() str

Returns a readable string representation of the type.

class FloatType

Bases: FractionType

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class IntegerType(signed=True)

Bases: IntegralType

name() Name

Returns the generic name of the type.

signed() bool

Returns True if the integer type is signed, False otherwise.

simple_string() str

Returns a readable string representation of the type.

class IntervalDayType

Bases: IntervalType

The interval day type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class IntervalYearType

Bases: IntervalType

The interval year type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class ListType(element_type: Type, element_nullable: bool)

Bases: ComplexType

A list type. Note, this type is not supported in the current version of Gravitino.

name() Name

Returns the generic name of the type.

classmethod not_null(element_type: Type) ListType

Create a new ListType with the given element type.

Args:

element_type: The element type of the list.

Returns:

A new ListType instance.

classmethod nullable(element_type: Type) ListType

Create a new ListType with the given element type and the type is nullable.

Args:

element_type: The element type of the list.

Returns:

A new ListType instance.

classmethod of(element_type: Type, element_nullable: bool) ListType

Create a new ListType with the given element type and whether the element is nullable.

Args:

element_type: The element type of the list. element_nullable: Whether the element of the list is nullable.

Returns

A new ListType instance.

simple_string() str

Returns a readable string representation of the type.

class LongType(signed=True)

Bases: IntegralType

name() Name

Returns the generic name of the type.

signed() bool

Returns True if the integer type is signed, False otherwise.

simple_string() str

Returns a readable string representation of the type.

class MapType(key_type: Type, value_type: Type, value_nullable: bool)

Bases: ComplexType

The map type in Gravitino. Note, this type is not supported in the current version of Gravitino.

name() Name

Returns the generic name of the type.

classmethod of(key_type: Type, value_type: Type, value_nullable: bool) MapType

Create a new MapType with the given key type, value type, and whether the value is nullable.

Args:

key_type: The key type of the map. value_type: The value type of the map. value_nullable: Whether the value of the map is nullable.

Returns:

A new MapType instance.

simple_string() str

Returns a readable string representation of the type.

classmethod value_not_null(key_type: Type, value_type: Type) MapType

Create a new MapType with the given key type, value type, and the value is not nullable.

Args:

key_type: The key type of the map. value_type: The value type of the map.

Returns:

A new MapType instance.

classmethod value_nullable(key_type: Type, value_type: Type) MapType

Create a new MapType with the given key type, value type, and the value is nullable.

Args:

key_type: The key type of the map. value_type: The value type of the map.

Returns:

A new MapType instance.

class NullType

Bases: Type

The data type representing NULL values.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class ShortType(signed=True)

Bases: IntegralType

name() Name

Returns the generic name of the type.

signed() bool

Returns True if the integer type is signed, False otherwise.

simple_string() str

Returns a readable string representation of the type.

class StringType

Bases: PrimitiveType

The string type in Gravitino, equivalent to varchar(MAX), which the MAX is determined by the underlying catalog.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class StructType(fields: List[Field])

Bases: ComplexType

The struct type in Gravitino. Note, this type is not supported in the current version of Gravitino.

name() Name

Returns the generic name of the type.

classmethod of(*fields) StructType
Args:

fields: The fields of the struct type.

Returns:

A StructType instance with the given fields.

simple_string() str

Returns a readable string representation of the type.

class TimeType

Bases: DateTimeType

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class TimestampType(with_time_zone: bool)

Bases: DateTimeType

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class UUIDType

Bases: PrimitiveType

The uuid type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

class UnionType(types: list[Type])

Bases: ComplexType

The union type in Gravitino. Note, this type is not supported in the current version of Gravitino.

name() Name

Returns the generic name of the type.

classmethod of(*types: Type) UnionType

Create a new UnionType with the given types.

Args:

types: The types of the union.

Returns:

A new UnionType instance.

simple_string() str

Returns a readable string representation of the type.

class UnparsedType(unparsed_type: str)

Bases: Type

Represents a type that is not parsed yet. The parsed type is represented by other types of types.

name() Name

Returns the generic name of the type.

classmethod of(unparsed_type: str) UnparsedType

Creates a new unparsed_type with the given unparsed type.

Args:

unparsed_type The unparsed type.

Returns

A new unparsed_type instance.

simple_string() str

Returns a readable string representation of the type.

class VarCharType(length: int)

Bases: PrimitiveType

The varchar type in Gravitino.

name() Name

Returns the generic name of the type.

simple_string() str

Returns a readable string representation of the type.

static allow_auto_increment(data_type: Type) bool

Checks if the given data type is allowed to be an auto-increment column.

Args:

data_type The data type to check.

Returns:

True if the given data type is allowed to be an auto-increment column, False otherwise.