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
ParameterTypeRequiredDescription
arrayARRAY<ROW<T>>YesArray 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 BIGINTf2 VARCHARf3 ARRAYf4 VARCHAR
1a[1, 2, 3]a

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19