All Products
Search
Document Center

MaxCompute:ARRAY

Last Updated:Jul 24, 2023

Creates an array based on given values.

Syntax

array array(<value>,<value>[, ...])

Parameters

value: required. A value of any data type. All values must be of the same data type.

Return value

A value of the ARRAY type is returned.

Examples

Create an array based on the data in the t_table table that contains the c1 (BIGINT), c2 (STRING), c3 (STRING), c4 (BIGINT), and c5 (BIGINT) columns. Data in the table:

+------------+----+----+------------+------------+
| c1         | c2 | c3 | c4         | c5         |
+------------+----+----+------------+------------+
| 1000       | k11 | k21 | 86         | 15         |
| 1001       | k12 | k22 | 97         | 2          |
| 1002       | k13 | k23 | 99         | 1          |
+------------+----+----+------------+------------+

Sample statement:

-- Create an array based on the data in the c2, c4, c3, and c5 columns. 
select array(c2,c4,c3,c5) from t_table;

-- The following result is returned: 
+------+
| _c0  |
+------+
| [k11, 86, k21, 15] |
| [k12, 97, k22, 2] |
| [k13, 99, k23, 1] |
+------+

Related functions

ARRAY is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.