下载hive源码
cd /root wget https://codeload.github.com/apache/hive/tar.gz/rel/release-3.1.1 wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.9/apache-hive-2.3.9-src.tar.gz wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-3.1.2/apache-hive-3.1.2-src.tar.gz
解压缩
cd /root tar -zxvf release-3.1.1/apache-hive-2.3.9-src.tar.gz/apache-hive-3.1.2-src.tar.gz
cd /root/hive-rel-release-3.1.1/ql/src/java/org/apache/hadoop/hive/ql/udf
将自己的定义的UDF java文件上传的上面这个目录下 : 进入udfjava文件,修改package -> org.apache.hadoop.hive.ql.udf ; cd …/exec/ 修改 vim FunctionRegistry.java import org.apache.hadoop.hive.ql.udf.HomeWorkAdd_RandomUDF20211231; 修改静态代码块:static{ 这里注意如果继承UDF,一定要有false参数,如果继承GenericUDF,则不用,否则会编译报错FunctionType类型转换异常 system.registerUDF(“substr”, HomeWorkAdd_RandomUDF20211231.class, false); }
mvn clean package -DskipTests -Phadoop-2 -Pdist 编译完成如上;
cd packaging/target/ cp apache-hive-3.1.1-bin.tar.gz 到目标路径解压即可
|