Skip to content

Instantly share code, notes, and snippets.

@tswann
Created December 23, 2014 15:21
Show Gist options
  • Save tswann/27ef26f354b4dcf5028b to your computer and use it in GitHub Desktop.
Save tswann/27ef26f354b4dcf5028b to your computer and use it in GitHub Desktop.
Soundex UDF wrapper for Hive.
@Description(name = "soundex",
value = "_FUNC_(string) - Retrieves the Soundex code for a given string.",
extended = "Example:\n"
+ " SELECT _FUNC_(input_string) FROM src;")
public final class SoundexUDF extends UDF {
public Text evaluate(final Text text) {
if (text == null) {
return null;
}
String soundex = new Soundex().soundex(text.toString());
return new Text(soundex);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment