Cree un arreglo a partir de los valores proporcionados.
Sintaxis
array array(<value>,<value>[, ...])
Parámetros
value: obligatorio. Un valor de cualquier tipo de dato. Todos los values deben ser del mismo tipo de dato.
Valor devuelto
Devuelve un valor de tipo ARRAY.
Ejemplos
Cree un arreglo con los datos de la tabla t_table, que contiene las columnas c1 (BIGINT), c2 (STRING), c3 (STRING), c4 (BIGINT), and c5 (BIGINT). Datos de la tabla:
+------------+----+----+------------+------------+
| c1 | c2 | c3 | c4 | c5 |
+------------+----+----+------------+------------+
| 1000 | k11 | k21 | 86 | 15 |
| 1001 | k12 | k22 | 97 | 2 |
| 1002 | k13 | k23 | 99 | 1 |
+------------+----+----+------------+------------+
Instrucción de ejemplo:
-- 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] |
+------+
Funciones relacionadas
ARRAY es una función de tipo complejo. Para obtener más información sobre las funciones utilizadas para procesar datos de tipos complejos, como ARRAY, MAP, STRUCT y JSON, consulte Complex type functions.