Skip to main content

ARRAY

ARRAY

ARRAY

Description

ARRAY\<T\>

This is an array of T-type items. It cannot be used as a key column. Currently ARRAY can only used in Duplicate Model Tables.

T-type could be any of:

BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE,
DATETIME, CHAR, VARCHAR, STRING

Note

You may use the following command to enable the array type:

$ mysql-client > admin set frontend config("enable_array_type"="true");

In this way the array type will be enabled after the FE process is restarted. Or you can add enable_array_type=true in fe.conf to keep it enabled permanently.

Example

Create table:

mysql> CREATE TABLE `array_test` (
`id` int(11) NULL COMMENT "",
`c_array` ARRAY<int(11)> NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
);

Insert data:

mysql> INSERT INTO `array_test` VALUES (1, [1,2,3,4,5]);
mysql> INSERT INTO `array_test` VALUES (2, [6,7,8]), (3, []), (4, null);

Note: The above SQL only supports array() function in non-vectorized scenarios.

Select data example:

mysql> SELECT * FROM `array_test`;
+------+-----------------+
| id | c_array |
+------+-----------------+
| 1 | [1, 2, 3, 4, 5] |
| 2 | [6, 7, 8] |
| 3 | [] |
| 4 | NULL |
+------+-----------------+

Keywords

ARRAY