v.22.1New Feature
Added arrayLast and arrayLastIndex functions
Added functionarrayLast. Closes #33390. #33415 Added functionarrayLastIndex. #33465 (Maksim Kita).
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 thearrayLast(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