- Categories:
Semi-structured and structured data functions (Array/Object)
ARRAY_ REPEAT¶
Returns an ARRAY value containing a specified number of copies of an element.
Syntax¶
Arguments¶
elementThe value to repeat in the output array.
The value can be of any semi-structured data type — for example, VARIANT, ARRAY, OBJECT — or any standard Snowflake data type — for example, NUMBER, VARCHAR, BOOLEAN, DATE.
Structured types, such as MAP, aren’t supported.
countAn INTEGER expression specifying the number of times to repeat
element.
Returns¶
The function returns a semi-structured ARRAY value containing count copies of
element.
If count is NULL, the function returns NULL.
Usage notes¶
- If
countis 0 or a negative number, the function returns an empty ARRAY. - If
elementis NULL, the function returns an ARRAY ofcountNULL values. - The
elementvalue is implicitly converted to VARIANT in the resulting ARRAY.
Examples¶
The following example repeats an INTEGER value three times:
The following example repeats a STRING value:
The following example repeats an ARRAY value to create a nested ARRAY:
The following example shows that a count of 0 returns an empty ARRAY value:
The following example shows that a NULL count returns NULL: