Skip to contents

Returns a transform that extracts the first or last element of an array-valued column. The result can be passed as the transform argument to il_compare() or il_block_on(), and composed with other transforms via il_transform(). On DuckDB and PostgreSQL, maps to SQL array indexing (col[1] or col[-1]).

Usage

il_array_element(position = c("first", "last"))

Arguments

position

Either "first" or "last".

Value

An il_column_transform closure.

Examples

tf <- il_array_element('first')
tf(list(c('Alice', 'A'), c('Bob'), character(0)))
#> [1] "Alice" "Bob"   NA