欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

hive udf

发布时间:2024/10/8 编程问答 33 豆豆
生活随笔 收集整理的这篇文章主要介绍了 hive udf 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

流程

  • 写java
  • 打jar包
  • add jar filePath(可本地,可hdfs)
  • create temporary function xxx as “your class”
  • // 1. 继承udf // 2. 实现evaluate方法 import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; public class UDFTest extents UDF {public Text evaluate(Text input){return new Text("hello:" + input.toString());} } <properties><hadoop.version>2.6.0</hadoop.version><hive.version>1.1.0</hive.version></properties><dependencies><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hive</groupId><artifactId>hive-exec</artifactId><version>${hive.version}</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency></dependencies>

    UDF种类

    function用法
    UDF
    genericUDF
    UDAF多进一出
    UDTF一进多出

    Reference

    https://blog.csdn.net/Gavin_chun/article/details/78169317
    https://blog.csdn.net/qq_34319644/article/details/95668820

    总结

    以上是生活随笔为你收集整理的hive udf的全部内容,希望文章能够帮你解决所遇到的问题。

    如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。