v.22.1New Feature

Added arrayLast and arrayLastIndex functions

Added function arrayLast. Closes #33390. #33415 Added function arrayLastIndex. #33465 (Maksim Kita).
Added new functions arrayLast and arrayLastIndex to ClickHouse for retrieving the last element of an array and the last index of a given element within an array, respectively.

Why it matters

These functions help users easily access the last element of an array or find the last occurrence index of a specific element within an array. This simplifies array operations and reduces the need for manual array manipulations or complex queries to achieve these common tasks.

How to use it

Use the arrayLast(array) function to get the last element of an array. Use arrayLastIndex(array, element) to find the last index of a specified element in the array. Example usage:

SELECT arrayLast([1, 2, 3, 4]);
-- Returns 4

SELECT arrayLastIndex([1, 2, 3, 2, 4], 2);
-- Returns 4