GENERATE_SERIES
Builds the series as an ARRAY in a single row. GENERATE_SERIES(10) starts at 1; GENERATE_SERIES(1, 10) and GENERATE_SERIES(1, 10, 2) start where they say. stop is included when it falls on a step boundary. A step pointing away from stop yields an EMPTY array; a step of zero is refused. Arguments must be CONSTANTS. With DATE or TIMESTAMP bounds and an INTERVAL step - GENERATE_SERIES(CAST('2025-01-01' AS TIMESTAMP), CAST('2025-01-02' AS TIMESTAMP), INTERVAL '5' MINUTE) - the result is an ARRAYFROM GENERATE_SERIES(1, 10) AS g, which also accepts floats and string dates. Without an alias the table spelling's column is named generate_series.
Category: Utility Functions
Syntax
GENERATE_SERIES(stop)GENERATE_SERIES(start, stop)GENERATE_SERIES(start, stop, step)Arguments
- stop
integer[constant] Last value of the series, included when it falls on a step boundary. Must be a constant expression. - start
integer[constant] First value of the series. Must be a constant expression. - step
integer[constant] Distance between consecutive values; may be negative, never zero. Must be a constant expression.
Returns
ARRAYARRAY<INT64>.
ARRAY<TIMESTAMP[US]> — Returns the computed result as ARRAY<TIMESTAMP[US]>.