Hive UDF 开发
来源:互联网 发布:董小飒淘宝 编辑:程序博客网 时间:2024/06/05 16:43
转自 http://richiehu.blog.51cto.com/2093113/386112
Hive进行UDF开发十分简单,此处所说UDF为Temporary的function,所以需要hive版本在0.4.0以上才可以。
Hive的UDF开发只需要重构UDF类的evaluate函数即可。例:
package com.hrj.hive.udf;
import org.apache.hadoop.hive.ql.exec.UDF;
public class helloUDFextends UDF {
public String evaluate(String str) {
try {
return "HelloWorld " + str;
} catch (Exception e) {
return null;
}
}
}
import org.apache.hadoop.hive.ql.exec.UDF;
public class helloUDFextends UDF {
public String evaluate(String str) {
try {
return "HelloWorld " + str;
} catch (Exception e) {
return null;
}
}
}
将该java文件编译成helloudf.jar
hive> add jar helloudf.jar;
hive> create temporary function helloworldas 'com.hrj.hive.udf.helloUDF';
hive> select helloworld(t.col1) from t limit 10;
hive> drop temporary function helloworld;
hive> create temporary function helloworldas 'com.hrj.hive.udf.helloUDF';
hive> select helloworld(t.col1) from t limit 10;
hive> drop temporary function helloworld;
注:
- helloworld为临时的函数,所以每次进入hive都需要add jar以及create temporary操作
- UDF只能实现一进一出的操作,如果需要实现多进一出,则需要实现UDAF
- 开发hive UDF函数
- Hive UDF 开发
- hive UDF开发注意事项
- hive开发UDF随记
- Hive UDF开发
- 开发hive UDF函数
- Hive UDF开发
- hive的udf开发
- Hive UDF开发指南
- Hive UDF开发
- hive UDF函数开发
- 开发hive UDF
- Hive UDF开发
- hive UDF开发实例
- Hive UDF开发
- Hive开发UDF
- Hive UDF开发初步
- hive udf&udaf开发
- Oracle学习笔记-0003
- 如何提高阅读源代码的效率
- LoadRunner二三事之——安装LoadRunner
- Qt中的QString和QByteArray
- 【iphone游戏开发】cocos2d和box2d API 文档
- Hive UDF 开发
- 说说win32多线程锁之临界区
- 【iphone游戏开发】iphone-Cocos2D游戏开发之一:游戏术语大解析
- 抽象类或接口的实例化问题
- 当一个表单中有多个按钮时,可以通过onclick()事件触发不同的action请求
- VC2010新增加对多线程的支持类
- 解决ie6下hover不识别问题
- 封装自己的静态库和应用
- 【iphone游戏开发】iphone-Cocos2D游戏开发之二:精灵表的详细讲解(一)和Zwoptex工具的使用