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

What Are Olap, Molap, Rolap, Dolap, Holap?
1. OLAP: On-Line Analytical Processing: Designates a category of applications and technologies that allow the collection, storage, manipulation and reproduction of multidimensional data, with the goal...

Lets look at Apache Spark's Competitors. Who are the top Competitors to Apache Spark today.
Apache Spark is the most popular open source product today to work with Big Data. More and more Big Data developers are using Spark to generate solutions for Big Data problems. It is the de-facto standard...
B

Biswanath Banerjee

1 0
0

Microsoft Outlook
Microsoft Outlook is the preferred email client used to access Microsoft Exchange Server email. Not only does Microsoft Outlook provide access to Exchange Server email, but it also includes contact, calendaring...

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...

Cloud Computing
Introduction: In online world, we get information with just one click. But where this all information is stored? How we can store so much data from anywhere and can access from everywhere. No time bound,...
N

Namrata Y.

1 0
0
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