INTINT NOT NULLDECIMAL(10, 2)TIMESTAMP(3) WITH LOCAL TIME ZONEROW<name STRING, score DOUBLE>ARRAY<BIGINT>
Using data types in Java
In the Java/Scala Table API, data types are instances oforg.apache.flink.table.types.DataType. All predefined types are available as static factory methods in org.apache.flink.table.api.DataTypes:
Using data types in Python
Supported types overview
| SQL type | Java type (DataTypes.*) | Description |
|---|---|---|
CHAR(n) | CHAR(n) | Fixed-length character string |
VARCHAR(n) / STRING | VARCHAR(n) / STRING() | Variable-length character string |
BINARY(n) | BINARY(n) | Fixed-length byte string |
VARBINARY(n) / BYTES | VARBINARY(n) / BYTES() | Variable-length byte string |
BOOLEAN | BOOLEAN() | True/false |
TINYINT | TINYINT() | 1-byte integer |
SMALLINT | SMALLINT() | 2-byte integer |
INT / INTEGER | INT() | 4-byte integer |
BIGINT | BIGINT() | 8-byte integer |
FLOAT | FLOAT() | 4-byte floating point |
DOUBLE | DOUBLE() | 8-byte floating point |
DECIMAL(p, s) | DECIMAL(p, s) | Fixed-precision decimal |
DATE | DATE() | Calendar date |
TIME(p) | TIME(p) | Time of day (precision 0 only) |
TIMESTAMP(p) | TIMESTAMP(p) | Date and time without time zone |
TIMESTAMP_LTZ(p) | TIMESTAMP_LTZ(p) | Date and time with local time zone |
INTERVAL YEAR TO MONTH | INTERVAL(YEAR(), MONTH()) | Year-month interval |
INTERVAL DAY TO SECOND | INTERVAL(DAY(), SECOND(3)) | Day-time interval |
ARRAY<T> | ARRAY(T) | Ordered sequence of elements |
MAP<K, V> | MAP(K, V) | Unordered key-value pairs |
MULTISET<T> | MULTISET(T) | Bag of values with duplicates |
ROW<f1 T1, ...> | ROW(FIELD("f1", T1), ...) | Structured record |
RAW<C> | RAW(C, serializer) | Opaque type for custom classes |
Character string types
CHAR(n) stores exactly n code points, padding shorter values with spaces. VARCHAR(n) stores up to n code points without padding. STRING is a synonym for VARCHAR(2147483647).
Numeric types
Exact integers
Decimal
DECIMAL(p, s) stores a number with exactly p total digits and s digits after the decimal point.
Floating point
FLOAT is 4-byte IEEE 754. DOUBLE is 8-byte IEEE 754. Use DECIMAL when you need exact arithmetic.
Date and time types
TIMESTAMP vs. TIMESTAMP_LTZ
TIMESTAMP(p) represents a date-time without any time zone information. TIMESTAMP_LTZ(p) represents an instant in time and is interpreted in the session’s local time zone when displaying. Use TIMESTAMP_LTZ for event-time attributes in streaming jobs.
Processing-time attribute
Date and time literals
Complex types
ARRAY
MAP
ROW
ROW is an anonymous structured type. Fields are accessed by name or position.
Nullability
All types are nullable by default. AppendNOT NULL to declare a non-null column:
Python and Java type mapping
The table below shows how Flink data types map to Python and Pandas types when used in Python UDFs:| Flink SQL type | Python type | Pandas type |
|---|---|---|
BOOLEAN | bool | numpy.bool_ |
TINYINT | int | numpy.int8 |
SMALLINT | int | numpy.int16 |
INT | int | numpy.int32 |
BIGINT | int | numpy.int64 |
FLOAT | float | numpy.float32 |
DOUBLE | float | numpy.float64 |
VARCHAR / STRING | str | str |
VARBINARY / BYTES | bytes | bytes |
DECIMAL | decimal.Decimal | decimal.Decimal |
DATE | datetime.date | datetime.date |
TIME | datetime.time | datetime.time |
TIMESTAMP | datetime.datetime | datetime.datetime |
TIMESTAMP_LTZ | datetime.datetime | datetime.datetime |
INTERVAL YEAR TO MONTH | int | Not supported |
INTERVAL DAY TO SECOND | datetime.timedelta | Not supported |
ARRAY | list | numpy.ndarray |
MAP | dict | Not supported |
ROW | pyflink.common.Row | dict |

