v.22.4New Feature

Added arrayFirstOrNull and arrayLastOrNull Functions

Added functions arrayFirstOrNull, arrayLastOrNull. Closes #35238. #35414 (Maksim Kita).
Added new functions arrayFirstOrNull and arrayLastOrNull to ClickHouse.

Why it matters

These functions provide a way to retrieve the first or last element of an array, returning NULL 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

Use arrayFirstOrNull 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;