[] (array construction)
On this page
Constructs an array from values of any type.
Syntax
[]
[<value>, ...]Arguments
| Argument | Type | Description |
|---|---|---|
<value> | Any type | Zero or more elements. Types may differ; NULL elements are retained. |
Returns
Returns array. With no elements, returns [].
Examples
Collect event labels
Combine fields from a request event into an array of labels:
VALUES ('checkout', 'timeout')
SELECT $0 AS service, $1 AS error
SELECT [service, error] AS labels+------------------------+
| labels |
+------------------------+
| ["checkout","timeout"] |
+------------------------+Keep structured steps in an event
An array can also contain objects. Keep the name and duration together for each checkout step:
SELECT [
{'step': 'cart', 'duration_ms': 80},
{'step': 'payment', 'duration_ms': 245}
] AS stepsThe steps value:
[
{
"duration_ms": 80,
"step": "cart"
},
{
"duration_ms": 245,
"step": "payment"
}
]