list_extract()

Extract the indexth (1-based) value from the list.

Reference: Haybarn WASM 2.0.0-rc12

Arguments & returns

2 overloads

list_extract(list, index)

Scalar
Overload link listindex Returns
#01 T[]BIGINT T

list_extract(string, index)

Scalar
Overload link stringindex Returns
#02 VARCHARBIGINT VARCHAR

Get an item by list position

Read one item from a SQL list using a one-based position. Negative positions count backward from the end.

An out-of-range position returns NULL. The last item is at position -1.

Get an item by list position
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Guide example · Run to view results.

Expected result
first_itemlast_itemoutside
applepearNULL

Watch for: SQL lists start at 1, while JSON array paths start at 0. Adjust positions when moving between the two representations.

Example

list_extract example
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Engine example · Run to view results.