Hive UDF开发
来源:互联网 发布:手机淘宝买家秀在哪里 编辑:程序博客网 时间:2024/06/07 20:31
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 helloUDF extends 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 helloworld as 'com.hrj.hive.udf.helloUDF';
hive> select helloworld(t.col1) from t limit 10;
hive> drop temporary function helloworld;
注:
1.helloworld为临时的函数,所以每次进入hive都需要add jar以及create temporary操作
Hive的UDF开发只需要重构UDF类的evaluate函数即可。例:
package com.hrj.hive.udf;
import org.apache.hadoop.hive.ql.exec.UDF;
public class helloUDF extends 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 helloworld as 'com.hrj.hive.udf.helloUDF';
hive> select helloworld(t.col1) from t limit 10;
hive> drop temporary function helloworld;
注:
1.helloworld为临时的函数,所以每次进入hive都需要add jar以及create temporary操作
2.UDF只能实现一进一出的操作,如果需要实现多进一出,则需要实现UDAF
0 0
- 开发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开发
- iOS开发者企业计划:D-U-N-S 号申请最新流程的心得
- 设置EditText光标位置
- 教你透彻了解红黑树
- 性能测试专家自学用书7本
- Libgdx的使用(1)——环境搭建
- Hive UDF开发
- 信号完整性研究系列--多长的走线才是传输线
- 在Android中创建卡片式UI
- Hive UDAF开发
- 写代码犹如写文章
- JAVA字符串
- C语言基本语法总结
- Offline Image Viewer Guide
- 文章代码背景