v.25.4New Feature

Add functions arrayLevenshteinDistance, arrayLevenshteinDistanceWeighted, and arraySimilarity

Add functions arrayLevenshteinDistance, arrayLevenshteinDistanceWeighted, and arraySimilarity. #77187 (Mikhail f. Shiryaev).
New array functions for similarity and distance calculation: added arrayLevenshteinDistance, arrayLevenshteinDistanceWeighted, and arraySimilarity functions.

Why it matters

These functions provide users with tools to measure the similarity or edit distance between arrays, which enables more advanced data comparison, fuzzy matching, and analysis of array-type data directly within ClickHouse.

How to use it

Use the functions in SQL queries as follows:

- <code>arrayLevenshteinDistance(array1, array2)</code> calculates the Levenshtein distance between two arrays.
- <code>arrayLevenshteinDistanceWeighted(array1, array2, weights)</code> calculates a weighted Levenshtein distance using a weights array.
- <code>arraySimilarity(array1, array2)</code> computes a similarity metric between two arrays.

Example:
SELECT arrayLevenshteinDistance([1,2,3], [1,2,4]) AS dist;