EDITDISTANCE

functionsupportedCore SQL functions

docs.snowflake.com ↗

String & binary functions

Computes the Levenshtein distance between two input strings. It is the number of single-character insertions, deletions, or substitutions needed to convert one string to another. Note Unlike some other metrics (for example, Damerau-Levenshtein distance), character transpositions aren’t considered.

Syntax

supportedpartialnot supportednot scored

EDITDISTANCE( <string_expr1> , <string_expr2> [ , <max_distance> ] )

Parameters

NameRequiredDescription
string_expr1, string_expr2requiredThe input strings.
max_distanceoptionalInteger expression that specifies the maximum distance to compute. When the distance between the strings exceeds this number, the function stops computing the distance and just returns the maximum distance. Specifying this argument has the same effect as calling LEAST( EDITDISTANCE( string_expr1, string_expr2 ), max_distance ). If you specify a negative number (that is, -n), the function uses 0 as the maximum distance and returns 0.

Usage notes

Collation details

No impact. In languages where the alphabet contains digraphs or trigraphs (such as “Dz” and “Dzs” in Hungarian), each character in each digraph and trigraph is treated as an independent character, not as part of a single multi-character letter. The result is based solely on the characters in the strings, not on the collation specifications of the strings.