Arrays

An array constructor is an expression that consists of a sequence of comma-separated expressions of the same type enclosed in square brackets. It produces an array value:

"[" expr [, ...] "]"

For example:

Copy
db> 
SELECT [1, 2, 3];
{[1, 2, 3]}
Copy
db> 
SELECT [('a', 1), ('b', 2), ('c', 3)];
{[('a', 1), ('b', 2), ('c', 3)]}

An empty array can also be created, but it must be used together with a type cast, since EdgeDB cannot determine the type of an array without having elements in it:

Copy
db> 
SELECT [];
QueryError: expression returns value of indeterminate type
Hint: Consider using an explicit type cast.
### SELECT [];
###        ^
Copy
db> 
SELECT <array<int64>>[];
{[]}

See also the list of array functions and operators.

Light
Dark
System