1、UDF的定义
UDF(User-Defined Functions)即是用户定义的hive函数。hive自带的函数并不能完全满足业务需求,这时就需要我们自定义函数了
UDF的分类
UDF:one to one,进来一个出去一个,row mapping。是row级别操作,如:upper、substr函数
UDAF:many to one,进来多个出去一个,row mapping。是row级别操作,如sum/min。
UDTF:one to many ,进来一个出去多个。如alteral view与explode
这三类中,我们只对UDF类的函数进行改写
2、UDF函数的编写
(1)pom文件配置
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.wsk.bigdata
g6-hadoop
1.0
g6-hadoop
1.7
1.7
UTF-8
2.6.0-cdh5.7.0
1.1.0-cdh5.7.0
nexus-aliyun
http://maven.aliyun.com/nexus/content/groups/public
cloudera
https://repository.cloudera.com/artifactory/cloudera-repos
org.apache.hadoop
hadoop-client
${hadoop.version}
junit
junit
4.11
test
org.apache.hive
hive-exec
${hive.version}
org.apache.maven.plugins
maven-compiler-plugin
2.4
1.7
1.7
UTF-8