EXTRACT
All functions > ARRAY_OF_ROWS > EXTRACT
Returns the extracted fields from the given expression.
Syntax
EXTRACT(base: ROW<T> or ARRAY<ROW<T>>, fields: FIELD or ARRAY<FIELD>) → V or ROW<V> or ARRAY<ROW<V>>
sql
Type Parameters:
T
: Any row typeV
: Extracted field type(s)
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
base | ROW<T> or ARRAY<ROW<T>> | Yes | Row or array of rows to extract from |
positions | ANY | Yes | Position(s) to extract (unused for field-only extraction) |
fields | FIELD or ARRAY<FIELD> | Yes | Field name(s) to extract |
as_fields | ANY | Yes | Optional renamed field name(s) in result |
Returns
Extracted field(s) as scalar, ROW, or ARRAY<ROW>
Notes
- Extracts one or more fields from ROW or ARRAY of rows
- Single field extraction returns scalar value
- Multiple field extraction returns ROW with selected fields
- For arrays of rows, transforms each element preserving array structure
- Can rename fields using as_fields parameter
- Supports both operator syntax (base[field]) and function syntax
- NULL handling: NULL rows return NULL fields