hive 添加UDF(user define function) hive的insert语句

add JAR /home/hadoop/study/study2/utf.jar;
package my.bigdata.udf;

import org.apache.hadoop.hive.ql.exec.UDF;

public class ToLowercase extends UDF {

    public String evaluate(String filed){
        
        return filed.toLowerCase();
    }
}

将代码达成jar包然后上传,其中依赖的函数在hive的压缩包的lib文件夹下面

创建临时函数 create temporary function  lowercase2  as 'my.bigdata.udf.ToLowercase';

使用时和其他函数一样

hive的insert 语句  insert into t_tmp values(17,"BABY"); 数据不会被追加在同一个文件(不会修改文件),而是在同文件夹下生成了一个文件,只有一条数据

posted @ 2017-06-06 21:37  牵牛花  阅读(371)  评论(0)    收藏  举报