Data Type Mapping
MySQL/TiDB Type Mapping
MySQL/TiDB Type | Paimon/Flink Type |
---|---|
BOOLEAN | |
TINYINT | TINYINT |
TINYINT UNSIGNED SMALLINT | SMALLINT |
SMALLINT UNSIGNED MEDIUMINT INT | INT |
INT UNSIGNED BIGINT | BIGINT |
DECIMAL(20, 0) | |
FLOAT FLOAT UNSIGNED | FLOAT |
REAL DOUBLE DOUBLE PRECISION | DOUBLE |
NUMERIC(p, s) DECIMAL(p, s) FIXED(p, s) | DECIMAL(p, s) |
DATE | DATE |
TIME [(p)] | TIME [(p)] |
TIMESTAMP [(p)] DATETIME [(p)] | TIMESTAMP [(p)] |
CHAR(n) VARCHAR(n) TEXT ENUM JSON | STRING |
BINARY VARBINARY BLOB | BYTES |
TINYINT(1)
is mapped to the BOOLEAN
type.
For TINYINT(1)
, the number 0
is converted to false
, and other numbers are converted to true
. This behavior follows the MySQL JDBC driver specification.BIGINT UNSIGNED
is mapped to DECIMAL(20, 0)
.
References:
Paimon Data Types
Category | Type | Description |
---|---|---|
Numeric | TINYINT | A 1-byte signed integer with a range from -128 to 127. |
Numeric | SMALLINT | A 2-byte signed integer with a range from -32,768 to 32,767. |
Numeric | INT | A 4-byte signed integer with a range from -2,147,483,648 to 2,147,483,647. |
Numeric | BIGINT | An 8-byte signed integer with a range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. |
Numeric | FLOAT | A 4-byte single-precision floating-point number. |
Numeric | DOUBLE | An 8-byte double-precision floating-point number. |
Numeric | DECIMAL(p, s) | A fixed-precision decimal number. p is the total number of digits (precision), and s is the number of digits after the decimal point (scale). For example, DECIMAL(10, 2). |
String | CHAR(n) | A fixed-length string with a length of n. |
String | VARCHAR(n) | A variable-length string with a maximum length of n. |
String | STRING | A variable-length string with virtually unlimited length. (Equivalent to VARCHAR(2147483647) in Flink). This is the most commonly used string type. |
Binary | BINARY(n) | Fixed-length binary data with a length of n. |
Binary | VARBINARY(n) | Variable-length binary data with a maximum length of n. |
Binary | BYTES | Variable-length binary data. (Equivalent to VARBINARY(2147483647) in Flink). |
Boolean | BOOLEAN | TRUE, FALSE, or NULL. |
Date | DATE | A date type, containing only year, month, and day. For example, 2023-10-27. |
Time | TIME(p) | A time type, containing only hour, minute, second, and fractional seconds. p is the precision of the fractional seconds, with a range from 0 to 9. |
DateTime | TIMESTAMP(p) or TIMESTAMP WITHOUT TIME ZONE | A timestamp without a time zone. It represents the literal time value regardless of the session's time zone. |
DateTime | TIMESTAMP_LTZ(p) or TIMESTAMP(p) WITH LOCAL TIME ZONE | A timestamp with a local time zone. When writing or reading, it is converted based on the Flink session's local time zone and stored as a UTC value in Paimon. For example, '2023-10-27 10:00:00' is written in a Flink session with the UTC+8 time zone. If the Flink session time zone is changed to UTC and the data is read, the result will be '2023-10-27 02:00:00'. |
Collection | ARRAY<T> | An array of elements with type T. For example, ARRAY<STRING>. |
Collection | MAP<K, V> | A map with key type K and value type V. For example, MAP<STRING, INT>. |
Collection | ROW<f1 T1, f2 T2, ...> or STRUCT<...> | A struct type, containing multiple named fields. For example, ROW<name STRING, age INT>. |