v.22.1New Feature
Added string manipulation functions and fixed substring error in ClickHouse
Addedleft,right,leftUTF8,rightUTF8functions. Fix error in implementation ofsubstringUTF8function with negative offset (offset from the end of string). #33407 (alexey-milovidov).
Why it matters
These additions provide more intuitive and efficient ways to extract substrings based on character count from either the start or end of strings, supporting both byte-wise and UTF-8 encodings. The fix forsubstringUTF8 ensures consistent and correct extraction when using negative offsets to specify positions from the string's end.How to use it
Use the new functions as follows:SELECT left(string, length) -- extracts the first <length> bytes
SELECT right(string, length) -- extracts the last <length> bytes
SELECT leftUTF8(string, length) -- extracts the first <length> UTF-8 characters
SELECT rightUTF8(string, length) -- extracts the last <length> UTF-8 charactersThe
substringUTF8 function now correctly accepts negative offsets to count from the end of the string:SELECT substringUTF8(string, -offset, length)