SQL Reference > Array Functions

Array Functions

This page covers functions for constructing and manipulating arrays in Rockset.

Refer also to the section on UNNEST for information on querying data inside arrays.

ARRAY_CREATE

ARRAY_CREATE(val1, val2, ...)

Construct an array from literals.

ARRAY_POSITION

ARRAY_POSITION(array, val)

Return a 1-based index of val if it is found within array. If val is null, it will return null. If val does not exist within array, it returns 0.

ARRAY_LAST_POSITION

ARRAY_LAST_POSITION(array, val)

Return a 1-based index of the last occurrence of val if it is found within array. If val is null, it will return null. If val does not exist within array, it returns 0.

LENGTH

LENGTH(array)

Returns length of array.

SLICE

SLICE(array, start[, length])

Returns a subset of array starting from index start (or starting from the end if start is negative) with a length of minimum of length and length of array. length is optional and defaults to length of array if unspecified.