editdistance

editdistance(str1: string, str2: string, [maxDistance: int64]?) -> int64

Returns the Levenshtein distance between str1 and str2.

Optional argument max_distance specifies a maximum distance to compute. If the computed distance reaches max_distance, the computation is stopped and max_distance is returned. A negative max_distance causes the function to use 0 as the max_distance and return 0. Empty str<> parameters return 0. A null value in either str1 or str2 or both returns null.

Domain

This is a scalar function (calculates a single output value for a single input row).

Categories

Examples

filter editdistance(name, last_name, 3) > 2

Filter rows whose name and last_name columns have an edit distance greater than two. Cap the computation at a max_distance of 3, since we don't care if the actual edit distance is larger.