@PublicEvolving public class DataTypes extends Object
DataType can be used to declare input and/or output types of operations. This class *
enumerates all pre-defined data types of Flink CDC.
NOTE:
| 构造器和说明 |
|---|
DataTypes() |
| 限定符和类型 | 方法和说明 |
|---|---|
static ArrayType |
ARRAY(DataType element)
Data type of an array of elements with same subtype.
|
static BigIntType |
BIGINT()
Data type of an 8-byte signed integer with values from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.
|
static BinaryType |
BINARY(int length)
Data type of a fixed-length binary string (=a sequence of bytes)
BINARY(n) where
n is the number of bytes. |
static BooleanType |
BOOLEAN()
Data type of a boolean with a (possibly) three-valued logic of
TRUE, FALSE, UNKNOWN. |
static VarBinaryType |
BYTES()
Data type of a variable-length binary string (=a sequence of bytes) with defined maximum
length.
|
static CharType |
CHAR(int length)
Data type of a fixed-length character string
CHAR(n) where n is the number of
code points. |
static DateType |
DATE()
Data type of a date consisting of
year-month-day with values ranging from 0000-01-01 to 9999-12-31. |
static DecimalType |
DECIMAL(int precision,
int scale)
Data type of a decimal number with fixed precision and scale
DECIMAL(p, s) where
p is the number of digits in a number (=precision) and s is the number of
digits to the right of the decimal point in a number (=scale). |
static DoubleType |
DOUBLE()
Data type of an 8-byte double precision floating point number.
|
static DataField |
FIELD(String name,
DataType type)
Field definition with field name and data type.
|
static DataField |
FIELD(String name,
DataType type,
String description)
Field definition with field name, data type, and a description.
|
static FloatType |
FLOAT()
Data type of a 4-byte single precision floating point number.
|
static OptionalInt |
getLength(DataType dataType) |
static OptionalInt |
getPrecision(DataType dataType) |
static OptionalInt |
getScale(DataType dataType) |
static IntType |
INT()
Data type of a 4-byte signed integer with values from -2,147,483,648 to 2,147,483,647.
|
static MapType |
MAP(DataType keyType,
DataType valueType)
Data type of an associative array that maps keys (including
NULL) to values
(including NULL). |
static RowType |
ROW(DataField... fields)
Data type of a sequence of fields.
|
static RowType |
ROW(DataType... fieldTypes)
Data type of a sequence of fields.
|
static SmallIntType |
SMALLINT()
Data type of a 2-byte signed integer with values from -32,768 to 32,767.
|
static DataType |
STRING()
Data type of a variable-length character string with defined maximum length.
|
static TimeType |
TIME()
Data type of a time WITHOUT time zone
TIME with no fractional seconds by default. |
static TimeType |
TIME(int precision)
Data type of a time WITHOUT time zone
TIME(p) where p is the number of digits
of fractional seconds (=precision). |
static LocalZonedTimestampType |
TIMESTAMP_LTZ()
Data type of a timestamp WITH LOCAL time zone
TIMESTAMP(p) WITH LOCAL TIME ZONE where
p is the number of digits of fractional seconds (=precision). |
static LocalZonedTimestampType |
TIMESTAMP_LTZ(int precision)
Data type of a timestamp WITH LOCAL time zone
TIMESTAMP WITH LOCAL TIME ZONE with 6
digits of fractional seconds by default. |
static ZonedTimestampType |
TIMESTAMP_TZ()
Data type of a timestamp WITH time zone
TIMESTAMP WITH TIME ZONE with 6 digits of
fractional seconds by default. |
static ZonedTimestampType |
TIMESTAMP_TZ(int precision)
Data type of a timestamp WITH time zone
TIMESTAMP(p) WITH TIME ZONE where p
is the number of digits of fractional seconds (=precision). |
static TimestampType |
TIMESTAMP()
Data type of a timestamp WITHOUT time zone
TIMESTAMP with 6 digits of fractional
seconds by default. |
static TimestampType |
TIMESTAMP(int precision)
Data type of a timestamp WITHOUT time zone
TIMESTAMP(p) where p is the number
of digits of fractional seconds (=precision). |
static TinyIntType |
TINYINT()
Data type of a 1-byte signed integer with values from -128 to 127.
|
static VarBinaryType |
VARBINARY(int n)
Data type of a variable-length binary string (=a sequence of bytes)
VARBINARY(n)
where n is the maximum number of bytes. |
static DataType |
VARCHAR(int n)
Data type of a variable-length character string
VARCHAR(n) where n is the
maximum number of code points. |
public static BinaryType BINARY(int length)
BINARY(n) where
n is the number of bytes. n must have a value between 1 and Integer.MAX_VALUE (both inclusive).BinaryTypepublic static VarBinaryType VARBINARY(int n)
VARBINARY(n)
where n is the maximum number of bytes. n must have a value between 1 and
Integer.MAX_VALUE (both inclusive).VarBinaryTypepublic static VarBinaryType BYTES()
VARBINARY(2147483647) for representing JVM byte
arrays.VarBinaryTypepublic static BooleanType BOOLEAN()
TRUE, FALSE, UNKNOWN.BooleanTypepublic static IntType INT()
IntTypepublic static TinyIntType TINYINT()
TinyIntTypepublic static SmallIntType SMALLINT()
SmallIntTypepublic static BigIntType BIGINT()
BigIntTypepublic static FloatType FLOAT()
FloatTypepublic static DoubleType DOUBLE()
DoubleTypepublic static CharType CHAR(int length)
CHAR(n) where n is the number of
code points. n must have a value between 1 and Integer.MAX_VALUE (both
inclusive).CharTypepublic static DataType VARCHAR(int n)
VARCHAR(n) where n is the
maximum number of code points. n must have a value between 1 and Integer.MAX_VALUE (both inclusive).VarCharTypepublic static DataType STRING()
VARCHAR(2147483647) for representing JVM strings.VarCharTypepublic static DecimalType DECIMAL(int precision, int scale)
DECIMAL(p, s) where
p is the number of digits in a number (=precision) and s is the number of
digits to the right of the decimal point in a number (=scale). p must have a value
between 1 and 38 (both inclusive). s must have a value between 0 and p (both
inclusive).DecimalTypepublic static DateType DATE()
year-month-day with values ranging from 0000-01-01 to 9999-12-31.
Compared to the SQL standard, the range starts at year 0000.
DataTypepublic static TimeType TIME()
TIME with no fractional seconds by default.
An instance consists of hour:minute:second with up to second precision and values
ranging from 00:00:00 to 23:59:59.
Compared to the SQL standard, leap seconds (23:59:60 and 23:59:61) are not supported as
the semantics are closer to LocalTime. A time WITH time zone is not
provided.
public static TimeType TIME(int precision)
TIME(p) where p is the number of digits
of fractional seconds (=precision). p must have a value between 0 and 9 (both
inclusive).
An instance consists of hour:minute:second[.fractional] with up to nanosecond
precision and values ranging from 00:00:00.000000000 to 23:59:59.999999999.
Compared to the SQL standard, leap seconds (23:59:60 and 23:59:61) are not supported as
the semantics are closer to LocalTime. A time WITH time zone is not
provided.
public static TimestampType TIMESTAMP()
TIMESTAMP with 6 digits of fractional
seconds by default.
An instance consists of year-month-day hour:minute:second[.fractional] with up to
microsecond precision and values ranging from 0000-01-01 00:00:00.000000 to 9999-12-31 23:59:59.999999.
Compared to the SQL standard, leap seconds (23:59:60 and 23:59:61) are not supported as
the semantics are closer to LocalDateTime.
TIMESTAMP(int),
TimestampTypepublic static TimestampType TIMESTAMP(int precision)
TIMESTAMP(p) where p is the number
of digits of fractional seconds (=precision). p must have a value between 0 and 9
(both inclusive).
An instance consists of year-month-day hour:minute:second[.fractional] with up to
nanosecond precision and values ranging from 0000-01-01 00:00:00.000000000 to 9999-12-31 23:59:59.999999999.
Compared to the SQL standard, leap seconds (23:59:60 and 23:59:61) are not supported as
the semantics are closer to LocalDateTime.
TimestampTypepublic static ZonedTimestampType TIMESTAMP_TZ()
TIMESTAMP WITH TIME ZONE with 6 digits of
fractional seconds by default.
An instance consists of year-month-day hour:minute:second[.fractional] zone with
up to microsecond precision and values ranging from 0000-01-01 00:00:00.000000 +14:59
to 9999-12-31 23:59:59.999999 -14:59.
Compared to the SQL standard, leap seconds (23:59:60 and 23:59:61) are not supported as
the semantics are closer to OffsetDateTime.
public static ZonedTimestampType TIMESTAMP_TZ(int precision)
TIMESTAMP(p) WITH TIME ZONE where p
is the number of digits of fractional seconds (=precision). p must have a value
between 0 and 9 (both inclusive).
An instance consists of year-month-day hour:minute:second[.fractional] zone with
up to nanosecond precision and values ranging from 0000-01-01 00:00:00.000000000
+14:59 to 9999-12-31 23:59:59.999999999 -14:59.
Compared to the SQL standard, leap seconds (23:59:60 and 23:59:61) are not supported as
the semantics are closer to OffsetDateTime.
public static LocalZonedTimestampType TIMESTAMP_LTZ()
TIMESTAMP(p) WITH LOCAL TIME ZONE where
p is the number of digits of fractional seconds (=precision). p must have a
value between 0 and 9 (both inclusive).
An instance consists of year-month-day hour:minute:second[.fractional] zone with
up to nanosecond precision and values ranging from 0000-01-01 00:00:00.000000000
+14:59 to 9999-12-31 23:59:59.999999999 -14:59. Leap seconds (23:59:60 and 23:59:61)
are not supported as the semantics are closer to OffsetDateTime.
Compared to ZonedTimestampType, the time zone offset information is not stored
physically in every datum. Instead, the type assumes Instant semantics in
UTC time zone at the edges of the table ecosystem. Every datum is interpreted in the local
time zone configured in the current session for computation and visualization.
This type fills the gap between time zone free and time zone mandatory timestamp types by allowing the interpretation of UTC timestamps according to the configured session timezone.
public static LocalZonedTimestampType TIMESTAMP_LTZ(int precision)
TIMESTAMP WITH LOCAL TIME ZONE with 6
digits of fractional seconds by default.
An instance consists of year-month-day hour:minute:second[.fractional] zone with
up to microsecond precision and values ranging from 0000-01-01 00:00:00.000000 +14:59
to 9999-12-31 23:59:59.999999 -14:59. Leap seconds (23:59:60 and 23:59:61) are not
supported as the semantics are closer to OffsetDateTime.
Compared to ZonedTimestampType, the time zone offset information is not stored
physically in every datum. Instead, the type assumes Instant semantics in
UTC time zone at the edges of the table ecosystem. Every datum is interpreted in the local
time zone configured in the current session for computation and visualization.
This type fills the gap between time zone free and time zone mandatory timestamp types by allowing the interpretation of UTC timestamps according to the configured session timezone.
public static ArrayType ARRAY(DataType element)
Compared to the SQL standard, the maximum cardinality of an array cannot be specified but
is fixed at Integer.MAX_VALUE. Also, any valid type is supported as a subtype.
Note: Flink CDC currently doesn't support defining nested array in columns.
ArrayTypepublic static MapType MAP(DataType keyType, DataType valueType)
NULL) to values
(including NULL). A map cannot contain duplicate keys; each key can map to at most
one value.
There is no restriction of key types; it is the responsibility of the user to ensure uniqueness. The map type is an extension to the SQL standard.
Note: Flink CDC currently doesn't support defining nested map in columns.
MapTypepublic static DataField FIELD(String name, DataType type)
public static DataField FIELD(String name, DataType type, String description)
public static RowType ROW(DataField... fields)
Compared to the SQL standard, an optional field description simplifies the handling with complex structures.
Use FIELD(String, DataType) or FIELD(String, DataType, String) to
construct fields.
Note: Flink CDC currently doesn't support defining nested row in columns.
RowTypepublic static RowType ROW(DataType... fieldTypes)
This is shortcut for ROW(DataField...) where the field names will be generated
using f0, f1, f2, ....
Note: Flink CDC currently doesn't support defining nested record in columns.
public static OptionalInt getPrecision(DataType dataType)
public static OptionalInt getLength(DataType dataType)
public static OptionalInt getScale(DataType dataType)
Copyright © 2025 The Apache Software Foundation. All rights reserved.