自定义函数

自定义UDF

1.导入依赖

<!-- https://mvnrepository.com/artifact/org.apache.hive/hive-exec -->
<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <version>3.1.2</version>
</dependency>

2.创建类,集成UDF,打jar,并放进hive/lib/目录下

3.在hive命令行中

add jar /jar包位置;
create function addFive as 全类名;

4.使用自定义函数

自定义UDTF

1.导入依赖

<!-- https://mvnrepository.com/artifact/org.apache.hive/hive-exec -->
<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <version>3.1.2</version>
</dependency>

2.创建类,集成GenericUDTF,实现方法

initialize(){}
process(){}
close(){}

3.在hive命令行中

add jar /jar包位置;
create function addFive as 全类名;

4.使用自定义函数

posted @ 2020-05-22 17:54  Q1Zhen  阅读(99)  评论(0编辑  收藏  举报