v.24.12New Feature

Function translate supports character deletion for mismatched argument lengths

Function translate now supports character deletion if the from argument contains more characters than the to argument. Example: SELECT translate('clickhouse', 'clickhouse', 'CLICK') now returns CLICK. #71441 (shuai.xu).
The translate function in ClickHouse now supports character deletion when the from argument has more characters than the to argument.

Why it matters

This enhancement allows users to remove specific characters from strings by mapping them to nothing, providing more flexible string manipulation capabilities within ClickHouse queries.

How to use it

Use the translate function with a from string longer than the to string. Characters in from that lack corresponding characters in to will be deleted. For example:

SELECT translate('clickhouse', 'clickhouse', 'CLICK')

returns:

CLICK