The first example of Hive UDF development

Source: Internet
Author: User

 PackageUDF;ImportOrg.apache.hadoop.hive.ql.exec.UDF; Public classHelloudfextendsudf{ Publicstring Evaluate (String str) {Try {return"HelloWorld" +str;} Catch(Exception e) {//Todo:handle Exceptionreturn NULL;}}} The above is the meaning of a UDF program written by Java project. Everyone should understand packaged as a jar: Before the Fat Jar blog was sent a jar package, and then exported to a jar to the Linux local directory into the Hiveadd jar/home/hadoop/udf_1_fat.jar;//Note that this address is a Linux local address, not an HDFS address that is not received unless you add HDFs links (no tests)CREATE temporary FUNCTION HelloWorld as ' udf.helloudf 'show functions can see all the supported methods, there will be HelloWorld find a table, there is a bit of data in my side looking for a table, I find out the data is: Hive> select * from hive1 limit 10; OK100 Flower Home Zhang Yunlong 18001295207 155 2 Room 1 Hall 1 Wei 94 2/5 floor North and South Sina Hebei chain Home2 China Yuwa small town Gao Wei 13501061874 210 3 Room 2 Hall 1 Wei 115 6/6 Floor North-South Sina Kelly Gate3 Golden Thai City Lai Wan Horse Harvest 18210989857 1200 5 Room 3 Hall 3 Wei 258 18/19-storey north-south Sina 21st century4 Love Day Green Island Yuhongliang 13366126543 430 3 Room 2 Hall 2 Wei 149 2/4-storey north-south Sina such as real estate5 YiHai Garden Hengtai Garden Shransen 18401296028 520 2 Room 2 Hall 2 Wei 136 15/28-storey West Sina I love my family .6 New Town View Yu Park Zhang Super 18910750910 180 2 Room 1 Hall 1 Wei 89 14/18 Floor North-South Sina Morning building Shun house7 dongrunfengjing Jingsun Center source 13501365333 380 2 Room 1 Hall 1 Wei 91 1/20-storey southeast Sina I love my family .8 Beiyuan home Hope Spring Garden Tektronix 18311385981 245 1 Room 1 Hall 1 Wei 69 17/25 floor Southeast Sina City bearing property9 Central Park Plaza Ludehui 15010507970 5800 1 Room 0 Hall 0 Wei 672 2/26 Floor South Sina Huaqing10 City second quarter Yang Yuiping 15001210716 200 4 Room 1 Hall 2 Wei 155 6/15-storey north-south Sina Hebei chain home field that's all we got. Hive is the result.> select HelloWorld (hive1.large) from hive1 limit 10; Okhelloworld94HelloWorld115HelloWorld258HelloWorld149HelloWorld136HelloWorld89HelloWorld91HelloWorld69HelloWorld672HelloWorld155Time taken:0.131 seconds, Fetched:10row (s) Hive> select HelloWorld (hive1.price) from hive1 limit 10; Okhelloworld155HelloWorld210HelloWorld1200HelloWorld430HelloWorld520HelloWorld180HelloWorld380HelloWorld245HelloWorld5800HelloWorld200Time taken:0.111 seconds, Fetched:10row (s) Hive> select HelloWorld (hive1.id) from hive1 limit 10; Okhelloworld1HelloWorld2HelloWorld3HelloWorld4HelloWorld5HelloWorld6HelloWorld7HelloWorld8HelloWorld9HelloWorld10Time taken:0.115 seconds, Fetched:10row (s) OK, everybody knows what it means.

The first example of Hive UDF development

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.