UrbanPro
true

Learn Hadoop from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How to create UDF (User Defined Function) in Hive

S
Sachin Patil
16/09/2018 0 0

1. User Defined Function (UDF) in Hive using Java.

2. Download hive-0.4.1.jar and add it to lib-> Buil Path -> Add jar to libraries

3. Q:Find the Cube of number passed:

import org.apache.hadoop.hive.ql.exec.UDF;

public class Cube extends UDF{

public int evaluate (int number)
{
return number*number*number;
}
}

4. Create jar file and copy to HDFS
terminal > sudo hadoop fs -put /home/cloudera/Desktop/Cube.jar /user/cloudera/

5. ADD JAR EXPORTED_FILE_NAME.jar;
hive> ADD JAR hdfs://quickstart.cloudera:8020/user/cloudera/Cube.jar;

6. hive> list jars;

7. Create Temperory function:
CREATE temporary function func_name as ‘absolute_class_name’.
hive> CREATE temporary function Cube as ‘Cube’;

8. hive> select Cube(marks) from student;

9. Create Permenent Function:
hive> CREATE function Cube as ‘Cube’ using jar ‘hdfs://quickstart.cloudera:8020/user/cloudera/Cube.jar’;

10. hive> select Cube(marks) from student;

0 Dislike
Follow 1

Please Enter a comment

Submit

Other Lessons for You

Dynamic HyerText Markup Language (DHTML)
Dynamic HyerText Markup Language (DHTML) is a combination of Web development technologies used to create dynamically changing websites. Web pages may include animation, dynamic menus and text effects....

Mail Merge In Word
Mail Merge is a useful tool that allows you to produce multiple letters, labels, envelopes, name tags, and more user information stored in a list, database, or spreadsheet. Mail Merge is most often used...

How Big Data Hadoop and its importance for an enterprise?
In IT phrasing, Big Data is characterized as a collection of data sets (Hadoop), which are so mind boggling and large that the data cannot be easily captured, stored, searched, shared, analyzed or visualized...

HTML (Hypertext Markup Language)
HTML (Hypertext Markup Language) is the set of markup symbols or codes inserted in a file intended for display on a World Wide Web browser page. The markup tells the Web browser how to display a Web page's...

R programming language
R is a programming language and software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing. The R language is widely used among statisticians and...
X

Looking for Hadoop Classes?

The best tutors for Hadoop Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Hadoop with the Best Tutors

The best Tutors for Hadoop Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more