UNWRAP
All functions > ARRAY OF ROWS > UNWRAP
Returns the first field values from an array of single-field rows as a simple array.
Signatures
Returns: Simple array of field values
UNWRAP(array: ARRAY<ROW<T>>) → ARRAY<T> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<ROW<T>> | Yes | Array of single-field rows |
Notes
- Extracts the first field from each row in the array
- Only works with arrays of rows that have exactly one field
- Throws error if rows have multiple fields
- Useful for converting aggregation results to simple arrays
Examples
FeatureQL
SELECT
f1 := UNWRAP(ARRAY(ROW(1), ROW(2), ROW(3))), -- Extract field values from array of rows
f2 := UNWRAP(ARRAY(ROW(ARRAY(1, 2, 3)))), -- Extract array field values
f3 := ARRAY(ROW('a'), ROW('b')).UNWRAP(), -- Method syntax for unwrapping
f4 := ARRAY(ROW('a')).UNWRAP() -- Single element unwrap
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY | f4 ARRAY |
|---|---|---|---|
| [1, 2, 3] | [[1, 2, 3]] | [a, b] | [a] |
On this page