Hologres data types are compatible with PostgreSQL data types. This topic describes the data and array types supported by Hologres.
Data types
Hologres data types are a subset of PostgreSQL data types. The following table lists the supported data types.
Data type | Supported version | Length | Description | Value range | Example |
INTEGER (INT or INT4) | All Hologres versions | 4 bytes | A standard integer. | -2147483648 to +2147483647 | 2147483647 |
BIGINT (INT8) | All Hologres versions | 8 bytes | A large-range integer. | -9223372036854775808 to +9223372036854775807 | 9223372036854775807 |
BOOLEAN (BOOL) | All Hologres versions | 1 byte | A Boolean type. |
| true |
REAL (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 | 6-digit decimal precision | 123.123 |
DOUBLE PRECISION (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. Use the | None | abcdefg |
TIMESTAMP WITH TIME ZONE (TIMESTAMPTZ) | All Hologres versions | 8 bytes | A timestamp with a time zone. The resolution is in milliseconds. Note In standard PostgreSQL, a | 4713 BC to 294276 AD | 2004-10-19 10:23:54+02 |
DECIMAL (NUMERIC) | All Hologres versions | Variable | You must specify the
| Up to 38 digits in total, including digits before and after the decimal point. | DECIMAL(38, 10) |
DATE | Hologres V0.8 and later | 4 bytes | A date. | 4713 BC to 5874897 AD | 2004-10-19 |
TIMESTAMP | Hologres V0.8 and later | 8 bytes | A timestamp without a time zone. The resolution is in microseconds. | 4713 BC to 5874897 AD | 2020-01-01 01:01:01.123456 |
CHAR(n) | Hologres V0.8 and later | Fixed-length, n characters. | A fixed-length string. If a string is shorter than | The storage size cannot exceed 1 GB. |
|
VARCHAR(n) | Hologres V0.8 and later | Variable-length, up to n characters. | A variable-length string with a length limit. | The storage size cannot exceed 1 GB. | abcdefg |
SERIAL | Hologres V0.8 and later | For more information, see PostgreSQL SERIAL. | An auto-incrementing integer sequence. | None | None |
SMALLINT | Hologres V0.9 and later | 2 bytes | A small-range integer. | -32768 to +32767 | 32767 |
JSON and JSONB | Hologres V0.9 and later | A data type for storing JSON data. | None | None | |
BYTEA | Hologres V0.9 and later | Variable. See Binary Data Types. | A variable-length binary string. | The storage size cannot exceed 1 GB. | None |
RoaringBitmap | Hologres V0.10 and later | Variable. See Roaring bitmap functions. | An efficient data structure for storing a compressed bitmap of | None | None |
RoaringBitmap64 | Hologres V3.1 and later | Variable. See Roaring bitmap functions. | An efficient data structure for storing a compressed bitmap of | None | None |
BIT(n) | Hologres V0.9 and later |
| A fixed-length bit string. | The storage size cannot exceed 1 GB. | None |
VARBIT(n) | Hologres V0.9 and later | Variable-length, up to | A variable-length bit string with a length limit. | The storage size cannot exceed 1 GB. | None |
INTERVAL | All Hologres versions | 16 bytes | A time span. | -178000000 years to 178000000 years | interval '1 year' |
TIMETZ | Hologres V0.9 and later | 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 | Hologres V0.9 and later | 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 | Hologres V0.9 and later | For more information, see Network Address Types. | An IPv4 or IPv6 host address. | None | 192.168.100.128/25 |
MONEY | Hologres V0.9 and later | 8 bytes. See Monetary types. | A currency amount with a fixed fractional precision. | -92233720368547758.08 to +92233720368547758.07 | $12.34 |
OID | Hologres V0.9 and later | 4 bytes | A numeric object identifier. | None | 1024 |
UUID | Hologres V0.9 and later | 16 bytes | A universally unique identifier with a fixed length of 128 bits. Note The algorithms implemented in | 00000000-0000-0000-0000-000000000000 to ffffffff-ffff-ffff-ffff-ffffffffffff | a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 |
The following SQL statements show 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 show examples of BIT, VARBIT, and BYTEA.
// BIT and VARBIT data types
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 data type
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
ARRAYkeyword.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 in an array.
SELECT int4_array[3] FROM array_example;Query multiple elements in 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 following table shows the data type mappings between MaxCompute and Hologres.
MaxCompute data type | Hologres data type | Supported Hologres version | Description |
| TEXT | All versions. | |
BIGINT | INT8 | All versions. | |
INT |
| All versions. | |
FLOAT |
| All versions. | |
DOUBLE |
| All versions. | |
BOOLEAN | BOOL | All versions. | |
DATETIME | TIMESTAMP WITH TIME ZONE | All versions. | The |
DECIMAL | NUMERIC | All versions. | If you do not specify the precision for the |
TIMESTAMP | TIMESTAMP WITH TIME ZONE | Hologres V0.8 and later. |
|
CHAR(n) | Defaults to You can also map it to | Hologres V0.8 and later. | The |
VARCHAR(n) | Defaults to You can also map it to | Hologres V0.8 and later. | The |
DATE | DATE | Hologres V0.8 and later. | |
SMALLINT | Defaults to You can also map it to | All versions. Maps to | |
TINYINT | Defaults to You can also map it to | All versions. Maps to | |
CHAR | Not supported. | N/A | |
ARRAY<INT> | INT4[] | Hologres V0.8 and later. | |
ARRAY<BIGINT> | INT8[] | Hologres V0.8 and later. | |
ARRAY<FLOAT> | FLOAT4[] | Hologres V0.8 and later. | |
ARRAY<DOUBLE> | FLOAT8[] | Hologres V0.8 and later. | |
ARRAY<BOOLEAN> | BOOLEAN[] | Hologres V0.8 and later. | |
ARRAY<STRING> | TEXT[] | Hologres V0.8 and later. | |
BINARY | BYTEA | Hologres V0.9 and later. | |
ARRAY<TINYINT> | Not supported. | Not supported. | |
ARRAY<SMALLINT> | Not supported. | Not supported. |
If a MaxCompute table contains fields of a data type that Hologres does not support, you can still query the table as long as your query does not access the unsupported fields.
Data type mappings between Flink/Blink and Hologres
The following table shows the data type mappings between Blink/Flink and Hologres.
Binlog source tables support only a subset of these data types. For more information, see Use Realtime Compute for Apache Flink or Blink to consume Hologres binary log data in real time.
Flink/Blink data type | Hologres data type | Supported Hologres version | Supported Flink/Blink version |
INT |
| All versions. | All versions. |
BIGINT | INT8 | All versions. | All versions. |
VARCHAR | TEXT | All versions. | All versions. |
DOUBLE |
| All versions. | All versions. |
BOOLEAN | BOOL | All versions. | All versions. |
DECIMAL | NUMERIC Note When you use CTAS to synchronize data to Hologres:
For more information, see FAQ about connectors | All versions. | All versions. |
DATE | DATE | Hologres V0.8 and later. | All versions. |
TIMESTAMP | TIMESTAMP WITH TIME ZONE | All versions. | All versions. |
FLOAT |
| All versions. | All versions. |
TIME | TIME and TIMETZ | All versions. Note In Hologres V2.1.24 or later, the TIME and TIMETZ data types are supported when you use the fixed plan feature to accelerate the execution of SQL statements. For more information, see Accelerate the execution of SQL statements by using fixed plans. |
|
VARCHAR | JSONB | Hologres V0.10 and later. |
|
VARCHAR | JSON | Hologres V0.9 and later. |
|
BYTES | RoaringBitmap | Hologres V0.10 and later. |
|
VARCHAR | GEOMETRY and GEOGRAPHY | All versions. Note As of Hologres v2.1, Fixed Plan supports writing data of the |
|
TINYINT | SMALLINT | All versions. |
|
SMALLINT | SMALLINT | All versions. |
|
ARRAY<INT> | int4[] | Hologres V0.8 and later. |
|
ARRAY<BIGINT> | int8[] | Hologres V0.8 and later. |
|
ARRAY<FLOAT> | float4[] | Hologres V0.8 and later. |
|
ARRAY<DOUBLE> | float8[] | Hologres V0.8 and later. |
|
ARRAY<BOOLEAN> | boolean[] | Hologres V0.8 and later. |
|
ARRAY<VARCHAR> | TEXT[] | Hologres V0.8 and later. |
|
CHAR | Not supported. | N/A | Not supported. |
BINARY | Not supported. | N/A | Not supported. |
Data type mappings between MySQL and Hologres
The following table shows the data type mappings between MySQL and Hologres. For more information, 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 Data Lake Formation (DLF) and Hologres
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 data 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 data types are supported:
|
Data type mappings between Apache Hudi and Hologres
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 data types are supported:
|
Data type mappings between Delta Lake and Hologres
This mapping is 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 data 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 data 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 |
TIMESTAMP | TIMESTAMP WITHOUT TIME ZONE |
TIMESTAMPTZ | Not supported. |
STRING | TEXT |
UUID | Not supported. Writers like Flink and Spark cannot write this type to Iceberg. |
FIXED(L) | BYTEA |
BINARY | BYTEA |
LIST | ARRAY<hologres_data_type> The following data types are supported:
|
STRUCT | Not supported. |
MAP | Not supported. |