- Categories:
Semi-structured and structured data functions (Array/Object)
ARRAY_PREPEND¶
Returns an array containing the new element as well as all elements from the source array. The new element is positioned at the beginning of the array.
- See also:
Syntax¶
ARRAY_PREPEND( <array> , <new_element> )
Arguments¶
arrayThe source array.
new_elementThe element to be prepended.
Returns¶
This returns the updated array.
Usage notes¶
When you pass a structured array to the function, the function returns a structured array of the same type.
If
arrayis a structured ARRAY, the type of the new element must be coercible to the type of the ARRAY.
Examples¶
The example below shows that the prepended element is placed at the beginning of the array:
SELECT ARRAY_PREPEND(ARRAY_CONSTRUCT(0,1,2,3),'hello'); +-------------------------------------------------+ | ARRAY_PREPEND(ARRAY_CONSTRUCT(0,1,2,3),'HELLO') | |-------------------------------------------------| | [ | | "hello", | | 0, | | 1, | | 2, | | 3 | | ] | +-------------------------------------------------+