一般来说你要是写的udf(例如floor,regexp_extract函数等)的参数和返回值只需要支持简单类型,例如 int double string这些类型,继承udf即可。
如果你的udf(例如size,collect_set函数)参数和返回值需要用到复杂类型,例如array map struct等,需要使用genericudf,这个里边需要进行参数类型的判断和获取等
最近感受了hive的udf函数的强大威力了,不仅可以使用很多已经有的udf函数,还可以自己定义符合业务场景的udf函数,下面就说一下如何写udf/udaf/udtf函数,算是一个入门介绍吧。
first, you need to create a new class that extends udf, with one or more methods named evaluate.
package com.example.hive.udf;
import org.apache.hadoop.hive.ql.exec.udf;
import org.apache.hadoop.io.text;
public final class lower extends udf {
public text evaluate(final text s) {
if (s == null) { return null; }
return new text(s.tostring().tolowercase());
Hadoop|
Apache Pig|
Apache Kafka|
Apache Storm|
Impala|
Zookeeper|
SAS|
TensorFlow|
人工智能基础|
Apache Kylin|
Openstack|
Flink|
MapReduce|
大数据|
云计算|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....