v.19.16New Feature

Add Function Arraysplit and Arrayreversesplit Which Split an Array by "cut Off" Conditions

Add function arraySplit and arrayReverseSplit which split an array by "cut off" conditions. They are useful in time sequence handling. #7294 (hcz)
Introduces two new array functions, arraySplit and arrayReverseSplit, which split an array into subarrays based on a specified "cut off" condition.

Why it matters

These functions address the need for advanced manipulation of array data, especially useful in handling time sequences and other ordered data. They enable splitting an array at positions determined dynamically by a predicate, allowing users to segment data efficiently within queries.

How to use it

Use arraySplit or arrayReverseSplit by passing a lambda function (predicate) that defines the cut off condition, and the array to be split. For example:

SELECT arraySplit(x -> x > 5, [1, 2, 6, 3, 7, 8])

This splits the array at elements where the condition is true. arrayReverseSplit works similarly but processes the array from the end.