This topic describes the data types that are supported by ApsaraDB for ClickHouse.
Supported data types
For information about all the data types that are supported by ClickHouse, see the Data Types topic of the open source ClickHouse documentation.
Category | Keyword | Data type | Valid value or description |
Integer |
| INT8 | Valid values: |
| Int16 | Valid values: | |
| Int32 | Valid values: | |
| Int64 | Valid values: | |
Floating-point |
| Single-precision floating-point type | Similar to a FLOAT value in the C++ programming language, a single-precision floating-point number takes up 4 bytes. Single-precision floating-point numbers are 32-bit binary data. |
| Double-precision floating-point type | Similar to a DOUBLE value in the C++ programming language, a double-precision floating-point number takes up 8 bytes. Double-precision floating-point numbers are 64-bit binary data. | |
Decimal |
| Decimal | DECIMAL values are signed fixed-point numbers. The numeric precision of these values can be maintained during the following mathematical operations: addition, subtraction, and multiplication. DECIMAL values can be in the following formats:
|
String |
| STRING | A string can be of a random length and can contain a random set of bytes, including null bytes. Therefore, the STRING type in ApsaraDB for ClickHouse is equivalent to the VARCHAR, BLOB, and CLOB types in other database management systems. |
FixedString | FIXEDSTRING | The FIXEDSTRING type is efficient when data has the length of precisely N bytes. In other cases, efficiency may be impaired. Examples of the values that can be efficiently stored in FIXEDSTRING-typed columns:
| |
Date and time |
| DATE | A DATE value takes up two bytes and indicates the number of days that have elapsed since Thursday, 1 January 1970. DATE values are unsigned. DATE values are stored without the time zone. |
| TIMESTAMP | A TIMESTAMP value takes up four bytes and indicates the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970. TIMESTAMP values are unsigned. The value range of the TIMESTAMP type is the same as the value range of the DATE type. The minimum TIMESTAMP value is 1970-01-01 00:00:00. TIMESTAMP values are accurate to seconds. Leap seconds are not supported. The time zone of a TIMESTAMP value is the system time zone of the related client or server. | |
| DATETIME64 | You can use this data type to store both the date and time of a specific point in time. | |
Boolean | Boolean | Boolean | ClickHouse does not support the BOOLEAN type. Use the UINT8 type for Boolean values. Valid values are 0 and 1. |
Array |
| ARRAY | An ARRAY value is a collection of elements of the same data type. The elements can be of a random data type, even the ARRAY type. However, we recommend that you do not use multi-dimensional arrays, because ClickHouse supports multi-dimensional arrays only to a limited extent. For example, multi-dimensional arrays cannot be stored in MergeTree tables. |
Tuple |
| TUPLE | A TUPLE value is a collection of elements of different data types. TUPLE values cannot be stored in tables, except for memory tables. You can use TUPLE values to group temporary columns. In queries, you can use IN expressions and lambda functions with specific parameters to group temporary columns. |
Domain |
| Domain | The implementation of the DOMAIN type varies based on different values: If the values are IPv4 addresses, the DOMAIN type is binary compatible with the UINT32 type. Compared with the UINT32 type, the DOMAIN type saves the binary storage space and supports more readable input and output formats. If the values are IPv6 addresses, the DOMAIN type is binary compatible with the FIXEDSTRING(16) type. Compared with the FIXEDSTRING(16) type, the DOMAIN type saves the binary storage space and supports more readable input and output formats. |
Enumeration |
| Enum8 | Valid values: |
| Enum16 | Valid values: | |
ENUM16 values can be empty. |
| Nullable | Unless otherwise stated in ClickHouse server configurations, the default value of the NULLABLE type is NULL. NULLABLE values cannot be included in table indexes. |
Nested |
| nested | A nested data structure is similar to a table inside a cell. You can specify the parameters of a nested data structure, such as field name and data type, the same way that you specify parameters in a CREATE TABLE statement. Each row in a CREATE TABLE statement can correspond to a random number of rows in a nested data structure. |