docs/en/sql-reference/sql-functions/array-functions/array_repeat.md
array_repeat returns an array containing a given element repeated a specified number of times.
array_repeat(element, count)
element: The element to be repeated can be any data type supported by StarRocks.
count: The number of repetitions, of type INT.
The data type of the return value is the ARRAY type of element.
Example 1:
select array_repeat(1,5) as res;
+-------------+
| res |
+-------------+
| [1,1,1,1,1] |
+-------------+
Example 2:
select array_repeat([1,2],3) as res;
+---------------------+
| res |
+---------------------+
| [[1,2],[1,2],[1,2]] |
+---------------------+
Example 3:
select array_repeat(1,-1) as res;
+------+
| res |
+------+
| [] |
+------+
Example 4:
select array_repeat(null,3) as res;
+------+
| res |
+------+
| NULL |
+------+
Example 5:
CREATE TABLE IF NOT EXISTS test (COLA INT, COLB INT) PROPERTIES ("replication_num"="1");
INSERT INTO test (COLA, COLB) VALUES (1, 3), (NULL, 3), (2, NULL);
select array_repeat(COLA,COLB) from test;
+--------------------------+
| array_repeat(COLA, COLB) |
+--------------------------+
| [1,1,1] |
| [null,null,null] |
| NULL |
+--------------------------+