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

Big Data & Hadoop - Introductory Session - Data Science for Everyone
Data Science for Everyone An introductory video lesson on Big Data, the need, necessity, evolution and contributing factors. This is presented by Skill Sigma as part of the "Data Science for Everyone" series.

Big Data for Gaining Big Profits & Customer Satisfaction in Retail Industry
For any business, the key success factor relies on its ability for finding the relevant information at the right time. In this digital world, it has become further crucial for the retailers to be aware...
K

Kovid Academy

5 1
1

Why is the Hadoop essential?
Capacity to store and process large measures of any information, rapidly. With information volumes and assortments always expanding, particularly from web-based life and the Internet of Things (IoT), that...

Big DATA Hadoop Online Training
Course Content for Hadoop DeveloperThis Course Covers 100% Developer and 40% Administration Syllabus.Introduction to BigData, Hadoop:- Big Data Introduction Hadoop Introduction What is Hadoop? Why Hadoop?...

Best and cheapest Seo Services in Delhi
www.sgttbinfotech.blogspot.in/
S
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