Hive Custom Function UDF example

Source: Internet
Author: User

Simple custom functions simply inherit the UDF class and then refactor the evaluate function to Lowercase.java:Package com.example.hiveudf;import Org.apache.hadoop.hive.ql.exec.UDF;Public final Class lowercase extends UDF {Public string Evaluate (final String s) {if (s = = null) {return null;}return new String (S.tostring (). toLowerCase ());  } }Dependent packages only HIVE-EXEC-0.13.1.JAR,MANIFEST.MF files are:manifest-version:1.0Class-path:Lib/hive-exec-0.13.1.jarMain-class:com.example.hiveudf.lowercaseExport the above Java file as Test.jar and upload it to a directory on the hive installation host, such as/usr/hive/test.jar to perform tests in hive:hive> add Jar/usr/hive/test.jar;hive>create temporary function mylower as ' com.example.hiveudf.LowerCase '; hive>select mylower (' ABCD ');Output: ABCD Delete temp function:hive>drop temporary function mylower;

Hive Custom Function UDF example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.