You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by Apache Wiki <wi...@apache.org> on 2010/12/17 04:48:18 UTC

[Hadoop Wiki] Update of "Hive/LanguageManual/UDF" by AdamKramer

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification.

The "Hive/LanguageManual/UDF" page has been changed by AdamKramer.
http://wiki.apache.org/hadoop/Hive/LanguageManual/UDF?action=diff&rev1=58&rev2=59

--------------------------------------------------

  ||string ||regexp_replace(string A, string B, string C) ||Returns the string resulting from replacing all substrings in B that match the Java regular expression syntax(See Java regular expressions syntax) with C e.g. regexp_replace("foobar", "oo|ar", "") returns 'fb.' Note that some care is necessary in using predefined character classes: using '\s' as the second argument will match the letter s; '\\s' is necessary to match whitespace, etc. ||
  ||string ||regexp_extract(string subject, string pattern, int intex) ||Returns the string extracted using the pattern. e.g. regexp_extract('foothebar', 'foo(.*?)(bar)', 2) returns 'bar.' Note that some care is necessary in using predefined character classes: using '\s' as the second argument will match the letter s; '\\s' is necessary to match whitespace, etc. ||
  ||string ||parse_url(string urlString, string partToExtract [, string keyToExtract]) ||Returns the specified part from the URL. Valid values for partToExtract include HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO. e.g. parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'HOST')  returns 'facebook.com'. Also a value of a particular key in QUERY can be extracted by providing the key as the third argument, e.g. parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'QUERY', 'k1')  returns 'v1'. ||
- ||string ||get_json_object(string json_string, string path) ||Extract json object from a json string based on json path specified, and return json string of the extracted json object. It will return null if the input json string is invalid ||
+ ||string ||get_json_object(string json_string, string path) ||Extract json object from a json string based on json path specified, and return json string of the extracted json object. It will return null if the input json string is invalid. '''NOTE: The json path can only have the characters [0-9a-z_], i.e., no upper-case or special characters. Also, the keys *cannot* start with numbers.''' This is due to restrictions on Hive column names. ||
  ||string ||space(int n) ||Return a string of n spaces ||
  ||string ||repeat(string str, int n) ||Repeat str n times ||
  ||int ||ascii(string str) ||Returns the numeric value of the first character of str ||