Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026.
We will start enforcing it in phases. For more information on the details of Python end of life
and migration options, see the
blog post
SUBARRAY function
Extracts a portion of an array starting from a specified position. Returns a new array containing the specified number of elements from the input array.
Syntax
SUBARRAY( super_expr, start_position, length )
Arguments
- super_expr
-
A valid SUPER expression in array form.
- start_position
-
An integer that specifies the starting position for extraction. The index is 0-based, where 0 indicates the first element. If start_position is beyond the array length, an empty array is returned.
- length
-
An optional integer that specifies the number of elements to extract. If omitted, all elements from the start position to the end of the array are returned.
Return type
The SUBARRAY function returns a SUPER data value.
Examples
The following is an example of a SUBARRAY function.
SELECT SUBARRAY(ARRAY('a', 'b', 'c', 'd', 'e', 'f'), 2, 3); subarray --------------- ["c","d","e"] (1 row)