REPEAT()

All functions > ARRAY > REPEAT()

Creates an array by repeating an element a specified number of times.

Signatures

Returns: Array with the element repeated count times

REPEAT(element: T, count: BIGINT) → ARRAY<T>
sql
ParameterTypeRequiredDescription
elementTYesThe element to repeat
countBIGINTYesNumber of times to repeat the element

Notes

  • Creates array with same element repeated multiple times
  • Count must be non-negative
  • Returns empty array if count is 0
  • Useful for generating test data or default values
  • Generic type: (T, BIGINT) → Array(T)
  • Supports ARRAY<ROW> elements (each repetition is an independent copy of the row)
  • Does not support ARRAY<ARRAY<T>> elements: DuckDB would flatten the array instead of nesting it; use ARRAY_CONCAT or TRANSFORM instead

See also

Examples

FeatureQL
SELECT
    f1 := REPEAT(7, 3), -- Repeat a scalar
    f2 := REPEAT('x', 2), -- Repeat strings
    f3 := REPEAT(1, 0) -- Zero repetitions
;
Result
f1 ARRAYf2 ARRAYf3 ARRAY
[7, 7, 7][x, x][]

Last update at: 2026/05/26 17:22:09