v.19.16New Feature
Add Function Arraysplit and Arrayreversesplit Which Split an Array by "cut Off" Conditions
Add functionarraySplitandarrayReverseSplitwhich split an array by "cut off" conditions. They are useful in time sequence handling. #7294 (hcz)
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
UsearraySplit 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.