@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    String str0 = getStringValue(arguments, 0, converters);
    String str1 = getStringValue(arguments, 1, converters);

    if (str0 == null || str1 == null) {
      return null;
    }

    int dist = StringUtils.getLevenshteinDistance(str0, str1);
    output.set(dist);
    return output;
  }
GenericUDFLevenshtein.

This function calculates the Levenshtein distance between two strings.
Levenshtein distance is a string metric for measuring the difference between
two sequences. Informally, the Levenshtein distance between two words is the
minimum number of single-character edits (i.e. insertions, deletions or
substitutions) required to change one word into the other. It is named after
Vladimir Levenshtein, who considered this distance in 1965
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLevenshtein.java