@PublicEvolving public final class DataTypes extends Object
DataType
can be used to declare input and/or output types of operations. This class
enumerates all predefined data types of the Table & SQL API.
NOTE: Planners might not support every data type with the desired precision or parameter. Please see the planner compatibility and limitations section in the website documentation before using a data type.
Modifier and Type  Class and Description 

static class 
DataTypes.Field
Helper class for defining the field of a row or structured type.

static class 
DataTypes.Resolution
Helper class for defining the resolution of an interval.

Modifier and Type  Method and Description 

static <T> DataType 
ANY(Class<T> clazz,
TypeSerializer<T> serializer)
Deprecated.
Use
RAW(Class, TypeSerializer) instead. 
static <T> DataType 
ANY(TypeInformation<T> typeInformation)
Deprecated.
Use
RAW(TypeInformation) instead. 
static DataType 
ARRAY(DataType elementDataType)
Data type of an array of elements with same subtype.

static DataType 
BIGINT()
Data type of an 8byte signed integer with values from 9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.

static DataType 
BINARY(int n)
Data type of a fixedlength binary string (=a sequence of bytes)
BINARY(n) where
n is the number of bytes. 
static DataType 
BOOLEAN()
Data type of a boolean with a (possibly) threevalued logic of
TRUE, FALSE, UNKNOWN . 
static DataType 
BYTES()
Data type of a variablelength binary string (=a sequence of bytes) with defined maximum length.

static DataType 
CHAR(int n)
Data type of a fixedlength character string
CHAR(n) where n is the number
of code points. 
static DataType 
DATE()
Data type of a date consisting of
yearmonthday with values ranging from 00000101
to 99991231 . 
static DataTypes.Resolution 
DAY()
Resolution in days with 2 digits for the number of days by default.

static DataTypes.Resolution 
DAY(int precision)
Resolution in days.

static DataType 
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 DataType 
DOUBLE()
Data type of an 8byte double precision floating point number.

static DataTypes.Field 
FIELD(String name,
DataType dataType)
Field definition with field name and data type.

static DataTypes.Field 
FIELD(String name,
DataType dataType,
String description)
Field definition with field name, data type, and a description.

static DataType 
FLOAT()
Data type of a 4byte single precision floating point number.

static DataTypes.Resolution 
HOUR()
Resolution in hours.

static DataType 
INT()
Data type of a 4byte signed integer with values from 2,147,483,648 to 2,147,483,647.

static DataType 
INTERVAL(DataTypes.Resolution resolution)
Data type of a temporal interval.

static DataType 
INTERVAL(DataTypes.Resolution upperResolution,
DataTypes.Resolution lowerResolution)
Data type of a temporal interval.

static DataType 
MAP(DataType keyDataType,
DataType valueDataType)
Data type of an associative array that maps keys (including
NULL ) to values (including
NULL ). 
static DataTypes.Resolution 
MINUTE()
Resolution in minutes.

static DataTypes.Resolution 
MONTH()
Resolution in months.

static DataType 
MULTISET(DataType elementDataType)
Data type of a multiset (=bag).

static DataType 
NULL()
Data type for representing untyped
NULL values. 
static <T> DataType 
RAW(Class<T> clazz,
TypeSerializer<T> serializer)
Data type of an arbitrary serialized type.

static <T> DataType 
RAW(TypeInformation<T> typeInformation)
Data type of an arbitrary serialized type backed by
TypeInformation . 
static DataType 
ROW(DataTypes.Field... fields)
Data type of a sequence of fields.

static DataTypes.Resolution 
SECOND()
Resolution in seconds with 6 digits for fractional seconds by default.

static DataTypes.Resolution 
SECOND(int precision)
Resolution in seconds and (possibly) fractional seconds.

static DataType 
SMALLINT()
Data type of a 2byte signed integer with values from 32,768 to 32,767.

static DataType 
STRING()
Data type of a variablelength character string with defined maximum length.

static DataType 
TIME()
Data type of a time WITHOUT time zone
TIME with no fractional seconds by default. 
static DataType 
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 DataType 
TIMESTAMP_WITH_LOCAL_TIME_ZONE()
Data type of a timestamp WITH LOCAL time zone
TIMESTAMP WITH LOCAL TIME ZONE with 6 digits
of fractional seconds by default. 
static DataType 
TIMESTAMP_WITH_LOCAL_TIME_ZONE(int precision)
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 DataType 
TIMESTAMP_WITH_TIME_ZONE()
Data type of a timestamp WITH time zone
TIMESTAMP WITH TIME ZONE with 6 digits of fractional
seconds by default. 
static DataType 
TIMESTAMP_WITH_TIME_ZONE(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 DataType 
TIMESTAMP()
Data type of a timestamp WITHOUT time zone
TIMESTAMP with 6 digits of fractional seconds
by default. 
static DataType 
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 DataType 
TINYINT()
Data type of a 1byte signed integer with values from 128 to 127.

static DataType 
VARBINARY(int n)
Data type of a variablelength 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 variablelength character string
VARCHAR(n) where n is the
maximum number of code points. 
static DataTypes.Resolution 
YEAR()
Resolution in years with 2 digits for the number of years by default.

static DataTypes.Resolution 
YEAR(int precision)
Resolution in years.

public static DataType CHAR(int n)
CHAR(n)
where n
is the number
of code points. n
must have a value between 1 and Integer.MAX_VALUE
(both inclusive).CharType
public 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).VarCharType
public static DataType STRING()
VARCHAR(2147483647)
for representing JVM strings.VarCharType
public static DataType BOOLEAN()
TRUE, FALSE, UNKNOWN
.BooleanType
public static DataType BINARY(int n)
BINARY(n)
where
n
is the number of bytes. n
must have a value between 1 and Integer.MAX_VALUE
(both inclusive).BinaryType
public static DataType 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).VarBinaryType
public static DataType BYTES()
VARBINARY(2147483647)
for representing JVM byte arrays.VarBinaryType
public static DataType 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).DecimalType
public static DataType TINYINT()
TinyIntType
public static DataType SMALLINT()
SmallIntType
public static DataType INT()
IntType
public static DataType BIGINT()
BigIntType
public static DataType FLOAT()
FloatType
public static DataType DOUBLE()
DoubleType
public static DataType DATE()
yearmonthday
with values ranging from 00000101
to 99991231
.
Compared to the SQL standard, the range starts at year 0000
.
DataType
public static DataType 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 DataType 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 DataType 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 yearmonthday hour:minute:second[.fractional]
with up to
nanosecond precision and values ranging from 00000101 00:00:00.000000000
to
99991231 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
.
public static DataType TIMESTAMP()
TIMESTAMP
with 6 digits of fractional seconds
by default.
An instance consists of yearmonthday hour:minute:second[.fractional]
with up to
microsecond precision and values ranging from 00000101 00:00:00.000000
to
99991231 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
.
public static DataType TIMESTAMP_WITH_TIME_ZONE(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 yearmonthday hour:minute:second[.fractional] zone
with up
to nanosecond precision and values ranging from 00000101 00:00:00.000000000 +14:59
to
99991231 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 DataType TIMESTAMP_WITH_TIME_ZONE()
TIMESTAMP WITH TIME ZONE
with 6 digits of fractional
seconds by default.
An instance consists of yearmonthday hour:minute:second[.fractional] zone
with up
to microsecond precision and values ranging from 00000101 00:00:00.000000 +14:59
to
99991231 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 DataType TIMESTAMP_WITH_LOCAL_TIME_ZONE(int precision)
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 yearmonthday hour:minute:second[.fractional] zone
with up
to nanosecond precision and values ranging from 00000101 00:00:00.000000000 +14:59
to
99991231 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 DataType TIMESTAMP_WITH_LOCAL_TIME_ZONE()
TIMESTAMP WITH LOCAL TIME ZONE
with 6 digits
of fractional seconds by default.
An instance consists of yearmonthday hour:minute:second[.fractional] zone
with up
to microsecond precision and values ranging from 00000101 00:00:00.000000 +14:59
to
99991231 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 DataType INTERVAL(DataTypes.Resolution resolution)
An interval of daytime consists of +days hours:months:seconds.fractional
with values
ranging from 999999 23:59:59.999999999
to +999999 23:59:59.999999999
. The type
must be parameterized to one of the following resolutions: interval of days, interval of days to
hours, interval of days to minutes, interval of days to seconds, interval of hours, interval of
hours to minutes, interval of hours to seconds, interval of minutes, interval of minutes to seconds,
or interval of seconds. The value representation is the same for all types of resolutions. For
example, an interval of seconds of 70 is always represented in an intervalofdaystoseconds
format (with default precisions): +00 00:01:10.000000
).
An interval of yearmonth consists of +yearsmonths
with values ranging from 999911
to +999911
. The type must be parameterized to one of the following resolutions: interval
of years, interval of years to months, or interval of months. The value representation is the
same for all types of resolutions. For example, an interval of months of 50 is always represented
in an intervalofyearstomonths format (with default year precision): +0402
.
Examples: INTERVAL(DAY(2))
for a daytime interval or INTERVAL(YEAR(4))
for
a yearmonth interval.
DayTimeIntervalType
,
YearMonthIntervalType
public static DataType INTERVAL(DataTypes.Resolution upperResolution, DataTypes.Resolution lowerResolution)
An interval of daytime consists of +days hours:months:seconds.fractional
with values
ranging from 999999 23:59:59.999999999
to +999999 23:59:59.999999999
. The type
must be parameterized to one of the following resolutions: interval of days, interval of days to
hours, interval of days to minutes, interval of days to seconds, interval of hours, interval of
hours to minutes, interval of hours to seconds, interval of minutes, interval of minutes to seconds,
or interval of seconds. The value representation is the same for all types of resolutions. For
example, an interval of seconds of 70 is always represented in an intervalofdaystoseconds
format (with default precisions): +00 00:01:10.000000
.
An interval of yearmonth consists of +yearsmonths
with values ranging from 999911
to +999911
. The type must be parameterized to one of the following resolutions: interval
of years, interval of years to months, or interval of months. The value representation is the
same for all types of resolutions. For example, an interval of months of 50 is always represented
in an intervalofyearstomonths format (with default year precision): +0402
.
Examples: INTERVAL(DAY(2), SECOND(9))
for a daytime interval or INTERVAL(YEAR(4), MONTH())
for a yearmonth interval.
DayTimeIntervalType
,
YearMonthIntervalType
public static DataType ARRAY(DataType elementDataType)
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.
ArrayType
public static DataType MULTISET(DataType elementDataType)
NULL
) is mapped to some
multiplicity.
There is no restriction of element types; it is the responsibility of the user to ensure uniqueness.
MultisetType
public static DataType MAP(DataType keyDataType, DataType valueDataType)
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.
MapType
public static DataType ROW(DataTypes.Field... fields)
Compared to the SQL standard, an optional field description simplifies the handling with complex structures.
RowType
public static DataType NULL()
NULL
values. A null type has no other value except
NULL
, thus, it can be cast to any nullable type similar to JVM semantics.
This type helps in representing unknown types in API calls that use a NULL
literal
as well as bridging to formats such as JSON or Avro that define such a type as well.
The null type is an extension to the SQL standard.
NullType
public static <T> DataType RAW(Class<T> clazz, TypeSerializer<T> serializer)
The raw type is an extension to the SQL standard.
This method assumes that a TypeSerializer
instance is present. Use RAW(TypeInformation)
for generating a serializer from Flink's core type system automatically in subsequent layers.
clazz
 originating value classserializer
 type serializerRawType
@Deprecated public static <T> DataType ANY(Class<T> clazz, TypeSerializer<T> serializer)
RAW(Class, TypeSerializer)
instead.public static <T> DataType RAW(TypeInformation<T> typeInformation)
TypeInformation
. This type is
a black box within the table ecosystem and is only deserialized at the edges.
The raw type is an extension to the SQL standard.
Compared to an RAW(Class, TypeSerializer)
, this type does not contain a TypeSerializer
yet. The serializer will be generated from the enclosed TypeInformation
but needs access
to the ExecutionConfig
of the current execution environment. Thus, this type is just a
placeholder.
TypeInformationRawType
@Deprecated public static <T> DataType ANY(TypeInformation<T> typeInformation)
RAW(TypeInformation)
instead.public static DataTypes.Resolution SECOND()
SECOND(int)
public static DataTypes.Resolution SECOND(int precision)
SECOND()
public static DataTypes.Resolution MINUTE()
public static DataTypes.Resolution HOUR()
public static DataTypes.Resolution DAY(int precision)
DAY()
public static DataTypes.Resolution DAY()
DAY(int)
public static DataTypes.Resolution MONTH()
public static DataTypes.Resolution YEAR(int precision)
YEAR()
public static DataTypes.Resolution YEAR()
YEAR(int)
public static DataTypes.Field FIELD(String name, DataType dataType)
public static DataTypes.Field FIELD(String name, DataType dataType, String description)
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.