An array T[]
is an ordered list of zero or more elements that share the same data type. PostgreSQL uses one-based indexing for arrays, meaning an array with n elements starts at array[1]
and ends at array[n]
. RisingWave also applies one-based indexing to align with PostgreSQL.
[]
to the data type of the column when you define the schema. For example, you can use trip_id VARCHAR[]
to create an array that stores trip IDs.
You can also define a temporary array in an SQL statement in this syntax:
x
that has an array of arrays.
taxi
that contains an array trip_id
.
[]
. For example, ARRAY ['ABCD1234', 'ABCD1235', 'ABCD1236', 'ABCD1237']
.
x
:
taxi
:
ARRAY_COLUMN[RELATIVE_POSITION]
syntax. Relative positions start from 1. For example, to access ABCD1234
, the first object in the trip_id
array, we can specify trip_id[1]
.
a
from the x
table.
trip_id
from the taxi
table.
ARRAY_COLUMN[n:m]
syntax, where n
and m
are integers representing indices and are both inclusive. Either n
, m
, or both can be omitted. Relative positions start from 1. In multidimensional arrays, arrays with unmatching dimensions are allowed.
n
omitted.
arr
is of type T[ ][ ][ ]:
[arr[x]](y)
, and of type T[ ][arr[x0:x1]](y0:y1)
, and of type T[ ][ ][ ][arr[x0:x1]](y)
, and of type T[ ][ ]arr
is still of type T[ ]:
NULL
valueunnest()
function to spread values in an array into separate rows.