v.22.4New Feature
Added arrayFirstOrNull and arrayLastOrNull Functions
Added functionsarrayFirstOrNull,arrayLastOrNull. Closes #35238. #35414 (Maksim Kita).
Why it matters
These functions provide a way to retrieve the first or last element of an array, returningNULL if the array is empty instead of raising an error. This improves query safety and convenience when working with arrays that might be empty.How to use it
UsearrayFirstOrNull to get the first element or arrayLastOrNull to get the last element of an array in your queries. For example:SELECT arrayFirstOrNull(x) FROM table;
SELECT arrayLastOrNull(x) FROM table;