Custom Functions -> UDF
01. Write a function to realize the value of the field attribute case conversion
Add hive file dependencies in pom.xml
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>0.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>0.13.1</version>
</dependency>
New ToLowCase class in maven project
package com.darrenzhang.hivedemo.hive_demo;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
public class ToLowCase extends UDF{
public Text evaluate(Text str){
if(str == null) return null;
if(str != null&& str.toString().length() <= 0) return null;
return new Text(str.toString().toLowerCase());
}
public static void main(String[] args){
System.out.println(new ToLowCase().evaluate(new Text(args[0])));
}
}
It is labeled jar package
And then has been next, finish it.
After labeled jar package, jia put this package to a temporary hive list