v.23.7New Feature

Another boring feature: add substring_index function like Spark or MySQL

Another boring feature: add function substring_index, as in Spark or MySQL. #51472 (李扬).
Added a new function substring_index to ClickHouse, similar to the functionality provided in Spark and MySQL.

Why it matters

The substring_index function allows users to extract substrings from a string before or after a specified delimiter, improving string manipulation capabilities within ClickHouse queries. This helps in parsing and processing delimited text data more easily.

How to use it

Use the substring_index function in your SQL queries with the syntax: substring_index(str, delim, count), where str is the input string, delim is the delimiter, and count specifies which portion to return (positive for left, negative for right). For example:

SELECT substring_index('a,b,c,d', ',', 2);
-- Returns 'a,b'