Skip to main content

ARRAY_REPEAT

Description​

Generates an array containing n repeated elements

Syntax​

ARRAY_REPEAT(<element>, <n>)

Parameters​

ParameterDescription
<n>Number of digits
<element>Specifying Elements

Return Value​

Returns an array containing n repeated elements. array_with_constant has the same function as array_repeat and is used to be compatible with the hive syntax format.

Example​

SELECT ARRAY_REPEAT("hello", 2),ARRAY_REPEAT(12345, 3);
+--------------------------+------------------------+
| array_repeat('hello', 2) | array_repeat(12345, 3) |
+--------------------------+------------------------+
| ["hello", "hello"] | [12345, 12345, 12345] |
+--------------------------+------------------------+