v.24.1New Feature

Add arrayShingles function for subarrays computation

Add function arrayShingles to compute subarrays, e.g. arrayShingles([1, 2, 3, 4, 5], 3) returns [[1,2,3],[2,3,4],[3,4,5]]. #58396 (Zheng Miao).
Introduces the arrayShingles function which generates all contiguous subarrays (shingles) of a specified length from an input array, e.g., arrayShingles([1, 2, 3, 4, 5], 3) returns [[1,2,3],[2,3,4],[3,4,5]].

Why it matters

The feature provides a convenient way to extract fixed-length contiguous segments (shingles) from arrays, which is useful for pattern analysis, sliding window computations, and breaking down sequences for further processing or comparison within ClickHouse.

How to use it

Invoke the function by passing an array and the desired length of shingles as arguments: arrayShingles(array, length). For example:

SELECT arrayShingles([1, 2, 3, 4, 5], 3)

This returns all contiguous subarrays of length 3 from the input array.