v.22.2Improvement

Optional Argument for splitByChar to Limit Resulting Elements

An optional argument for splitByChar to limit the number of resulting elements. close #34081. #34140 (李扬).
Added an optional argument to the splitByChar function that limits the number of elements returned after splitting a string by a specified character.

Why it matters

This feature allows users to control the number of resulting substrings when splitting a string, which helps optimize performance and memory usage by avoiding unnecessary processing of all split elements.

How to use it

Use the splitByChar function with an additional optional integer argument specifying the maximum number of elements to return. For example:

SELECT splitByChar(',', 'a,b,c,d,e', 3)

This will return only the first three elements resulting from the split.