editdistance¶
Description¶
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
.
Return type¶
int64
Domain¶
This is a scalar function (calculates a single output value for a single input row.)
Categories¶
Usage¶
editdistance(str1, str2, [ maxDistance ])
Argument |
Type |
Optional |
Repeatable |
Restrictions |
---|---|---|---|---|
str1 |
string |
no |
no |
none |
str2 |
string |
no |
no |
none |
maxDistance |
int64 |
yes |
no |
none |
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.