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

Hadoop v/s Spark
1. Introduction to Apache Spark: It is a framework for performing general data analytics on distributed computing cluster like Hadoop.It provides in memory computations for increase speed and data process...

How To Be A Hadoop Developer?
i. Becoming a Hadoop Developer: Dice survey revealed that 9 out of 10 high paid IT jobs require big data skills. A McKinsey Research Report on Big Data highlights that by end of 2018 the demand for...

REFERENCE BOOKS FOR DATA SCIENCE
Dear All, You can use the following books to master the DATA SCIENCE Concepts 1) First Course in Probability-Ronald Russel 2)Applied Regression Analysis-Drapper and Smith 3)Applied Multivariate Analysis-Richard...

CheckPointing Process - Hadoop
CHECK POINTING Checkpointing process is one of the vital concept/activity under Hadoop. The Name node stores the metadata information in its hard disk. We all know that metadata is the heart core...

Lesson: Hive Queries
Lesson: Hive Queries This lesson will cover the following topics: Simple selects ? selecting columns Simple selects – selecting rows Creating new columns Hive Functions In SQL, of which...
C
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