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