eclipse下编写hive udf函数
来源:互联网 发布:刺客信条 mac字幕 编辑:程序博客网 时间:2024/06/04 19:39
Eclipse下新建java project,编写转换小写测试函数:
package com.tom;import org.apache.hadoop.hive.ql.exec.UDF;import org.apache.hadoop.io.Text;public class HiveUDF extends UDF{public Text evaluate(final Text str) {if(str == null) return null;return new Text(str.toString().toLowerCase());}}
关联jar包:
hive-exec-0.13.1.jarhadoop-common-2.5.1.jar
右键export打包为udf_toLower.jar文件,传到hive主机/root/udfs下。
在hive中添加jar包:
hive> add jar /root/udfs/udf_toLower.jar; Added /root/udfs/udf_toLower.jar to class pathAdded resource: /root/udfs/udf_toLower.jar
创建udf:
hive> create temporary function lower as 'com.tom.HiveUDF';OKTime taken: 0.021 seconds
测试:
hive> select * from user;OK1 DUSIZHONG2 TOM3 JIMTime taken: 0.811 seconds, Fetched: 3 row(s)hive> select lower(name) from user;Total jobs = 1Launching Job 1 out of 1Number of reduce tasks is set to 0 since there's no reduce operatorStarting Job = job_1415866521696_0023, Tracking URL = http://master:8088/proxy/application_1415866521696_0023/Kill Command = /usr/hadoop/bin/hadoop job -kill job_1415866521696_0023Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 02014-11-20 16:43:47,391 Stage-1 map = 0%, reduce = 0%2014-11-20 16:43:56,965 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 2.62 secMapReduce Total cumulative CPU time: 2 seconds 620 msecEnded Job = job_1415866521696_0023MapReduce Jobs Launched: Job 0: Map: 1 Cumulative CPU: 2.62 sec HDFS Read: 227 HDFS Write: 18 SUCCESSTotal MapReduce CPU Time Spent: 2 seconds 620 msecOKdusizhongtomjimTime taken: 34.496 seconds, Fetched: 3 row(s)
删除udf:
hive> drop temporary function lower;OKTime taken: 0.016 seconds
0 0
- eclipse下编写hive udf函数
- 利用eclipse编写自定义hive udf函数
- 利用eclipse编写自定义hive udf函数
- Hive编写UDF函数
- 使用eclipse编写UDF函数
- 编写hive udf和使用hive udf:hue的hive界面中使用hive udf函数、oozie使用hive udf函数、hive命令行使用udf函数
- 编写hive udf和使用hive udf:hue的hive界面中使用hive udf函数、oozie使用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函数使用
- C#读取文件,返回字符串形式的文件内容
- inner join on, left join on, right join on,逗号
- java抽象类和接口的区别
- ASP.net 后台获取前台 客户端标签
- 最近的感悟
- eclipse下编写hive udf函数
- phoneGap-Android开发环境搭建
- perl获取当前执行文件的路径
- 第十二周上机项目2--(3) 刑警的射击成绩
- Hadoop学习笔记
- hdu1507——Uncle Tom's Inherited Land*
- Convert Sorted Array(List) to Binary Search Tree,Validate Binary Search Tree
- 传送流的(半关闭)
- 数据库的读写分离