package com.hadoop.hive;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
class toUpper extends UDF {
public Text evaluate(Text input) {
if(input == null) return null;
return new Text(input.toString().toUpperCase());
}
}
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
class toUpper extends UDF {
public Text evaluate(Text input) {
if(input == null) return null;
return new Text(input.toString().toUpperCase());
}
}
1.
CRATE ABOVE JAVA CODE
UNDER ECLLIPSE --> NEW PROJECT--> UNDER PACKAGE
com.hadoop.hive
create a new class named toUpper
2.
create and export jar file to /home/training
3.
Add jar file in to hive as below
4.
hive> add jar /home/training/toup.jar
> ;
Added /home/training/toup.jar to class path
Added resource: /home/training/toup.jar
5.
create temporary function as below
hive> create temporary function up as 'com.hadoop.hive.toUpper';
OK
Time taken: 0.01 seconds
6.
execute ur table data with that function as below
hive> select up(ename) from emp;
Total MapReduce jobs = 1
Launching Job 1 out of 1
---
--
Ended Job = job_201703031523_0002
OK
AAA
BBB
CCC
DDD
EEE
No comments:
Post a Comment