hive udf

来源:互联网 发布:淘宝药店 提交需求 编辑:程序博客网 时间:2024/05/16 15:31

1.

package com.hrj.hive.udf;

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

public classmyUDF extends UDF {

    public String evaluate(String str) {

        try {

            return "HelloWorld " + str;

        } catch (Exception e) {

            return null;

        }

    }

}

2.导出jar包

3. hive> add jar myudf.jar;

4.为java的类名起一个别名

hive> create temporary function helloworld as 'com.hrj.hive.udf.myUDF';

5.测试

hive> select myworld("111") from t limit 10;

0 0
原创粉丝点击