ARRAY

description

ARRAY\<T>

An array of T-type items, it cannot be used as a key column. Now ARRAY can only used in Duplicate Model Tables.

T-type could be any of:

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

notice

We should turn on the switch for the ARRAY types feature with the following command before use:

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

In this way the config will be reset after the FE process restarts. For permanent setting, you can add config enable_array_type=true inside fe.conf.

example

Create table example:

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

Insert data example:

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

Note: The above sql supports the array() function only in non-vectorized scenarios, but not in vectorized scenarios.

Select data example:

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

keywords

  1. ARRAY