EXTRACT(...)

All functions > ARRAY OF ROWS > EXTRACT(...)

Returns the extracted fields from the given expression.

Syntax

base[ field | * | -field, ... ]

Notes

  • Extracts fields from a ROW or an array of rows. Bracket items run left to right.
  • x and x AS y copy from the source row; * copies remaining source fields; -x removes an output name already selected
  • A single unaliased field (R[a]) is a scalar. A keep list, *, -name, or AS produces a ROW, including when one field remains
  • On an array of rows the same bracket applies to each element
  • NULL rows or missing fields yield NULL where appropriate
  • Operator form: base[field], base[*, -field]; EXTRACT(...) is the call equivalent
  • Date EXTRACT(UNIT FROM ts) is not this function — write DATE_PART(ts, 'year')

Related Functions

See also

Examples

FeatureQL
RETURN
    -- Project one field from an array of rows
    f1 := (ARRAY(ROW(10 AS x, 20 AS y), ROW(30 AS x, 40 AS y)))[x]
;
Result
f1 ARRAY
[10, 30]