Hologres data types are compatible with PostgreSQL data types. This topic describes the data and array types that Hologres supports.
Data types
The current version of Hologres supports a subset of PostgreSQL data types. The following table lists the supported data types.
Name | Supported version | Storage size | Description | Value range | Example |
INTEGER (alias: INT or INT4) | All Hologres versions | 4 bytes | Common integer types | -2147483648 to +2147483647 | 2147483647 |
BIGINT (alias: INT8) | All Hologres versions | 8 bytes | A large-range integer. | -9223372036854775808 to +9223372036854775807 | 9223372036854775807 |
BOOLEAN (alias: BOOL) | All Hologres versions | 1 byte | A Boolean type. |
| True |
REAL (alias: FLOAT4) | All Hologres versions | 4 bytes | A variable-precision, inexact number. Note In the PostgreSQL ecosystem, if you do not specify the precision for the FLOAT type, it defaults to DOUBLE PRECISION (FLOAT8). | 6-digit decimal precision. | 123.123 |
DOUBLE PRECISION (alias: FLOAT8) | All Hologres versions | 8 bytes | A variable-precision, inexact number. | 15-digit decimal precision. | 123.123456789123 |
TEXT | All Hologres versions | Variable length | A variable-length string. The TEXT type is more flexible than VARCHAR(n) and CHAR(n). We recommend that you use the TEXT type instead of VARCHAR(n) or CHAR(n). | None | abcdefg |
TIMESTAMP WITH TIME ZONE (alias: TIMESTAMPTZ) | All Hologres versions | 8 bytes | A timestamp with a time zone. The storage precision is in milliseconds. Note Standard PostgreSQL uses the + or - symbol and the subsequent time zone offset of | 4713 BC to 294276 AD | 2004-10-19 10:23:54+02 |
DECIMAL (alias: NUMERIC) | All Hologres versions | Variable-length | You must specify PRECISION and SCALE.
| Up to 38 digits can be specified, including the integer and fractional parts. | DECIMAL(38, 10) |
DATE | What's new in Hologres V0.8 | 4 bytes | The unit is measured in days. | 4713 BC to 5874897 AD | 2004-10-19 |
TIMESTAMP | What's New in Hologres V0.8 | 8 bytes | A timestamp without a time zone. The storage precision is in microseconds. | 4713 BC to 5874897 AD | 2020-01-01 01:01:01.123456 |
CHAR(n) | What's New in Hologres V0.8 | A fixed-length string of up to n characters. | The storage size cannot exceed 1 GB. | A fixed-length character string. |
|
VARCHAR(n) | What's New in Hologres V0.8 | A variable-length string of up to n characters. | The storage size cannot exceed 1 GB. | A variable-length string with a character limit. | abcdefg |
SERIAL (auto-incrementing sequence) | This feature is available in Hologres V0.8 and later versions. | For more information, see auto-incrementing sequence. | None | None | None |
SMALLINT | What's new in Hologres V0.9 | 2 bytes | A small-range integer. | -32768 to +32767 | 32767 |
JSON and JSONB | What's New in Hologres V0.9 | For more information, see JSON data types. | None | None | None |
BYTEA | Introduced in Hologres V0.9 | Variable. For more information, see Binary Data Types. | A variable-length binary string. | The storage size cannot exceed 1 GB. | None |
RoaringBitmap | What's New in Hologres V0.10 | Variable. For more information, see RoaringBitmap functions. | An efficient array of INT values that supports constant-time bitmap computation. | None | None |
RoaringBitmap64 | What's new in Hologres V3.1 | Variable. For more information, see RoaringBitmap functions. | An efficient array of BIGINT values that supports constant-time bitmap computation. | None | None |
BIT(n) | What's New in Hologres V0.9 | A binary string of n bits in length. | A fixed-length binary string. | The storage size cannot exceed 1 GB. | None |
VARBIT(n) | Hologres V0.9 | A variable-length binary string of up to n bits in length. | A binary string with a bit length limit. | The storage size cannot exceed 1 GB. | None |
INTERVAL | All Hologres versions | 16 bytes | None | -178000000 years to 178000000 years | interval '1 year' |
TIMETZ | What's new in Hologres V0.9 | 12 bytes | The time of day with a time zone. The resolution is in microseconds. | 00:00:00 to 24:00:00 | 12:00:00+08 |
TIME | This feature was introduced in Hologres V0.9. | 8 bytes | The time of day without a time zone. The resolution is in microseconds. | 00:00:00 to 24:00:00 | 12:00:00 |
INET | What's New in Hologres V0.9 | For more information, see Network Address Types. | An IPv4 or IPv6 host address stored in a data domain. | None | 192.168.100.128/25 |
MONEY | What's New in Hologres V0.9 | 8 bytes. See Monetary types. | The money type stores a currency amount with a fixed fractional precision. | -92233720368547758.08 to +92233720368547758.07 | $12.34 |
OID | What's New in Hologres 0.9 | 4 bytes | A numeric object identifier. | None | 1024 |
UUID | What's new in Hologres V0.9 | 16 bytes | A universally unique identifier with a fixed length of 128 bits. Note The algorithms implemented in uuid-ossp are not currently supported. | 00000000-0000-0000-0000-000000000000~ffffffff-ffff-ffff-ffff-ffffffffffff | a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 |
The following SQL statements are examples of TIMESTAMP WITH TIME ZONE, DATE, and DECIMAL.
CREATE TABLE test_data_type (
tswtz_column TIMESTAMP WITH TIME ZONE,
date_column date,
decimal_column decimal(38, 10),
char_column char(20),
varchar_volumn varchar(225)
);
INSERT INTO test_data_type
VALUES ('2004-10-19 08:08:08', '2004-10-19', 123.456, 'abcd', 'a');
SELECT * FROM test_data_type;
tswtz_column | date_column | decimal_column | char_column | varchar_volumn
------------------------+-------------+----------------+----------------------+----------------
2004-10-19 08:08:08+08 | 2004-10-19 | 123.4560000000 | abcd | a
(1 row)The following SQL statements are examples of BIT, VARBIT, and BYTEA.
// BIT and VARBIT
CREATE TABLE test (a BIT(3), b BIT VARYING(5));
INSERT INTO test VALUES (B'101', B'00');
INSERT INTO test VALUES (B'10', B'101');
ERROR: bit string length 2 does not match type bit(3)
INSERT INTO test VALUES (B'10'::bit(3), B'101');
SELECT * FROM test;
a | b
-----+-----
101 | 00
100 | 101
// BYTEA
SET bytea_output = 'escape';
SELECT 'abc \153\154\155 \052\251\124'::bytea;
bytea
----------------
abc klm *\251T
RESET bytea_output; -- 'hex' by default
SELECT 'abc \153\154\155 \052\251\124'::bytea;
bytea
--------------------------
\x616263206b6c6d202aa954
(1 row)Array types
Hologres currently supports only the following one-dimensional arrays:
int4[]
int8[]
float4[]
float8[]
boolean[]
text[]
Examples:
Declare an array.
CREATE TABLE array_example( int4_array int4[], int8_array int8[], float4_array float4[], float8_array float8[], boolean_array boolean[], text_array text[]);Insert arrays.
Use the ARRAY keyword.
INSERT INTO array_example( int4_array, int8_array, float4_array, float8_array, boolean_array, text_array) VALUES (ARRAY[1, 2, 3, 4], ARRAY[1, 2, 3, 4], ARRAY[1.0, 2.0], ARRAY[1.0, 2.0, 3.0], ARRAY[true, true, false], ARRAY['foo1', 'foo2', 'foo3']);Use the
{}expression.INSERT INTO array_example( int4_array, int8_array, float4_array, float8_array, boolean_array, text_array) VALUES ('{1, 2, 3, 4}', '{1, 2, 3, 4}', '{1.0, 2.0}', '{1.0, 2.0, 3.0}', '{true, true, false}', '{"foo1", "foo2", "foo3"}');
Query an array.
Query a single element from an array.
SELECT int4_array[3] FROM array_example;Query multiple elements from an array.
SELECT int4_array[1:2] FROM array_example;
Data type mappings between MaxCompute and Hologres
When you create a foreign table to access MaxCompute data, the data types are mapped between MaxCompute and Hologres as shown in the following table.
MaxCompute data type | Hologres data type | Supported mapping version | Description |
JSON | JSONB | New in Hologres V4.1 | |
| TEXT | All Hologres versions | None |
BIGINT | INT8 | All Hologres versions | None |
INT |
| All Hologres versions | None |
FLOAT |
| All Hologres versions | None |
DOUBLE |
| All Hologres versions | None |
BOOLEAN | BOOL | All Hologres versions | None |
DATETIME | TIMESTAMP WITH TIME ZONE | All Hologres versions | The DATETIME type in MaxCompute is a date and time type that uses the UTC+8 time zone as the system standard time. The value ranges from January 1, 0000 to December 31, 9999, with millisecond precision. |
DECIMAL | NUMERIC | All Hologres versions | If you do not specify the precision for the DECIMAL type in MaxCompute, the precision defaults to (38, 18). When you use IMPORT FOREIGN SCHEMA to create a table, the system automatically converts the precision. |
TIMESTAMP | TIMESTAMP WITH TIME ZONE | What's New in Hologres 0.8 |
|
CHAR(n) | Defaults to CHAR(n). Hologres also supports mapping the CHAR(n) type of MaxCompute to the TEXT type. You need to set the | What's New in Hologres V0.8 | The CHAR(n) type in MaxCompute is a fixed-length character type, where n is the length. The maximum value of n is 255. If a string is shorter than the specified length, it is padded with spaces. |
VARCHAR(n) | Defaults to VARCHAR(n). Hologres also supports mapping the VARCHAR(n) type of MaxCompute to the TEXT type. You need to set the | What's New in Hologres V0.8 | The VARCHAR(n) type in MaxCompute is a variable-length character type, where n is the length. The value of n ranges from 1 to 65535. |
DATE | DATE | What's New in Hologres V0.8 | None |
SMALLINT | Defaults to INT2. Hologres also supports mapping the SMALLINT type of MaxCompute to the INT8 type. You need to set the | All Hologres versions (maps to int4 in V0.8 and int2 in V0.9 and later) | None |
TINYINT | Defaults to INT2. Hologres also supports mapping the TINYINT type of MaxCompute to the INT8 type. You need to set the | All Hologres versions (maps to int4 in V0.8 and int2 in V0.9 and later) | None |
CHAR | Not supported | Not supported | None |
ARRAY<INT> | INT4[] | What's New in Hologres V0.8 | None |
ARRAY<BIGINT> | INT8[] | What's New in Hologres V0.8 | None |
ARRAY<FLOAT> | FLOAT4[] | What's New in Hologres V0.8 | None |
ARRAY<DOUBLE> | FLOAT8[] | What's new in Hologres V0.8 | None |
ARRAY<BOOLEAN> | BOOLEAN[] | What's New in Hologres V0.8 | None |
ARRAY<STRING> | TEXT[] | What's new in Hologres V0.8 | None |
BINARY | BYTEA | What's New in Hologres V0.9 | None |
ARRAY<TINYINT> | Not supported | Not supported | None |
ARRAY<SMALLINT> | Not supported | Not supported | None |
If a MaxCompute data table contains fields of a data type that Hologres does not support, you can still query the other fields in the table. However, you cannot access the fields with unsupported data types.
Data type mappings between Blink/Flink and Hologres
The following table shows the data type mappings between Blink/Flink and Hologres.
Source tables for binary logging support only some data types. For more information, see Consume Hologres binary logs in real time using Blink or Flink.
Flink data type | Hologres data type | Supported Hologres mapping version | Supported Flink mapping version |
INT |
| All Hologres versions | All versions |
BIGINT | INT8 | All Hologres versions | All versions |
VARCHAR | TEXT | All Hologres versions | All versions |
DOUBLE |
| All Hologres versions | All versions |
BOOLEAN | BOOL | All Hologres versions | All versions |
DECIMAL | NUMERIC Note When you use CTAS to synchronize data to Hologres:
For more information, see Why is the primary key of a MySQL table with a bigint unsigned type changed to decimal after the table is registered with a Flink catalog, and then changed to text after the data is synchronized to Hologres using CTAS?. | All Hologres versions | All versions |
DATE | DATE | What's new in Hologres V0.8 | All versions |
TIMESTAMP | TIMESTAMP WITH TIME ZONE | All Hologres versions | All versions |
FLOAT |
| All Hologres versions | All versions |
TIME | TIME and TIMETZ | All Hologres versions Note Starting from Hologres V2.1.24, accelerating SQL execution using fixed plans supports the TIME and TIMETZ types. |
|
VARCHAR | JSONB | What's New in Hologres V0.10 |
|
VARCHAR | JSON | What's New in Hologres V0.9 |
|
BYTES | RoaringBitmap | What's new in Hologres V0.10 |
|
VARCHAR | GEOMETRY and GEOGRAPHY | All Hologres versions Note Starting from Hologres V2.1, accelerating SQL execution using fixed plans supports writing data of the GEOMETRY and GEOGRAPHY types. |
|
TINYINT | SMALLINT | All Hologres versions |
|
SMALLINT | SMALLINT | All Hologres versions |
|
ARRAY<INT> | int4[] | What's new in Hologres V0.8 |
|
ARRAY<BIGINT> | int8[] | What's New in Hologres V0.8 |
|
ARRAY<FLOAT> | float4[] | What's new in Hologres V0.8 |
|
ARRAY<DOUBLE> | float8[] | What's New in Hologres V0.8 |
|
ARRAY<BOOLEAN> | boolean[] | What's new in Hologres V0.8 |
|
ARRAY<VARCHAR> | TEXT[] | What's new in Hologres V0.8 |
|
CHAR | Not supported | Not supported | Not supported |
BINARY | Not supported | Not supported | Not supported |
Data type mappings between MySQL and Hologres
The following table shows the data type mappings between MySQL and Hologres. For more information about how to migrate data from MySQL to Hologres, see Migrate data from MySQL to Hologres.
MySQL data type | Hologres data type |
BIGINT | BIGINT |
BINARY(n) | BYTEA |
BIT | BOOLEAN |
|
|
DATE | DATE |
DATETIME | TIMESTAMP [WITHOUT TIME ZONE] |
|
|
DOUBLE | DOUBLE PRECISION |
FLOAT | REAL |
|
|
MEDIUMINT | INTEGER |
NUMERIC(p,s) | NUMERIC(p,s) |
SMALLINT | SMALLINT |
| BYTEA |
TINYINT | SMALLINT |
| TEXT |
TIME | TIME [WITHOUT TIME ZONE] |
TIMESTAMP | TIMESTAMP [WITH TIME ZONE] |
| BYTEA |
VARCHAR(n) | VARCHAR(n) |
VARCHAR(max) | TEXT |
Data type mappings between DLF and Hologres
Data Lake Formation (DLF) data type | Hologres data type |
TINYINT | SMALLINT |
SMALLINT | SMALLINT |
INT | INT |
BIGINT | BIGINT |
BOOLEAN | BOOLEAN |
FLOAT | REAL |
DOUBLE | DOUBLE PRECISION |
DATE | DATE |
TIMESTAMP | TIMESTAMP WITHOUT TIME ZONE |
STRING | TEXT |
BINARY | BYTEA |
DECIMAL(m,n) | NUMERIC(m,n) |
VARCHAR(n) | CHARACTER VARYING(n) |
CHAR(n) | CHARACTOR(n) |
ARRAY<type> | ARRAY<hologres_data_type> The following types are supported:
|
Data type mappings between Hive and Hologres
Hive data type | Hologres data type |
TINYINT | SMALLINT |
SMALLINT | SMALLINT |
INT | INT |
BIGINT | BIGINT |
FLOAT | REAL |
DOUBLE | DOUBLE PRECISION |
DECIMAL | NUMERIC |
NUMERIC | NUMERIC |
DATE | DATE |
TIMESTAMP | TIMESTAMP WITHOUT TIME ZONE |
STRING | TEXT |
VARCHAR | VARCHAR |
CHAR | CHAR |
BINARY | BYTEA |
BOOL | BOOLEAN |
ARRAY<type> | ARRAY<hologres_data_type> The following types are supported:
|
Data type mappings between Hudi and Hologres
Supported in Hologres V1.3 and later.
Hudi data type | Hologres data type |
IntegerType | INT |
LongType | BIGINT |
FloatType | REAL |
DoubleType | DOUBLE PRECISION |
DecimalType | NUMERIC |
TimestampType | TIMESTAMP WITHOUT TIME ZONE |
DateType | DATE |
YearMonthIntervalType | Not supported |
DayTimeIntervalType | Not supported |
StringType | TEXT |
VarcharType | Not supported |
CharType | Not supported |
BooleanType | BOOL |
BinaryType | BYTEA |
ByteType | Not supported |
ShortType | Not supported |
ArrayType(elementType, containsNull) | ARRAY<hologres_data_type> The following types are supported:
|
Data type mappings between Delta Lake and Hologres
Supported in Hologres V1.3 and later.
Delta Lake data type | Hologres data type |
TINYINT | SMALLINT |
SMALLINT | SMALLINT |
INT | INT |
BIGINT | BIGINT |
FLOAT | REAL |
DOUBLE | DOUBLE PRECISION |
DECIMAL(p,s) | NUMERIC |
TIMESTAMP | TIMESTAMP WITHOUT TIME ZONE |
DATE | DATE |
INTERVAL intervalQualifier | Not supported |
STRING | TEXT |
BOOLEAN | BOOLEAN |
BINARY | BYTEA |
ARRAY<elementType> | ARRAY<hologres_data_type> The following types are supported:
|
Data type mappings between Paimon and Hologres
Paimon data type | Hologres data type |
TINYINT | SMALLINT |
SMALLINT | SMALLINT |
INT | INT |
BIGINT | BIGINT |
FLOAT | REAL |
DOUBLE | DOUBLE PRECISION |
DECIMAL(p,s) | DECIMAL |
TIMESTAMP | TIMESTAMP WITHOUT TIME ZONE |
DATE | DATE |
CHAR | CHAR |
VARCHAR | VARCHAR |
BINARY | BYTEA |
ARRAY | ARRAY<hologres_data_type> The following types are supported:
|
Data type mappings between Iceberg and Hologres
Iceberg data type | Hologres data type |
BOOLEAN | BOOLEAN |
INT | INTEGER |
LONG | BIGINT |
FLOAT | REAL |
DOUBLE | DOUBLE PRECISION |
DECIMAL(P,S) | NUMERIC(P,S) |
DATE | DATE |
TIME | TEXT (The TIME type is not supported by Spark. The TIME type in Flink is converted to the STRING type when written to DLF.) |
TIMESTAMP | TIMESTAMP WITHOUT TIME ZONE |
TIMESTAMPTZ | Not supported |
STRING | TEXT |
UUID | Not supported (Flink and Spark cannot write this data type.) |
FIXED(L) | BYTEA |
BINARY | BYTEA |
LIST | ARRAY<hologres_data_type> The following types are supported:
|
STRUCT | Not supported |
MAP | Not supported |