Skip to Content
Apache Hive Cookbook
book

Apache Hive Cookbook

by Hanish Bansal, Saurabh Chauhan, Shrey Mehrotra
April 2016
Beginner content levelBeginner
268 pages
5h 32m
English
Packt Publishing
Content preview from Apache Hive Cookbook

Creating custom User-Defined Functions (UDF)

Built-in functions in Hive sometimes do not fit the requirements of a business use case or when data analytics required some custom manipulation of data based on certain conditions. For such cases, the user needs to define custom logic as a UDF and run it over the data.

How to do it…

For writing a custom function in Hive, you will have to extend a Hive class: org.apache.hadoop.hive.ql.exec.UDF.

Let's understand the concept of creating a custom UDF with the example of creating a function to reverse a string.

The following are the steps to create a custom UDF:

  1. Create a new Java project using any IDE, such as Eclipse. Give this any name; let's say "HiveUDF".
  2. When writing a custom UDF, there should be two libraries ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Introduction to Apache Hive

Introduction to Apache Hive

Tom Hanlon

Publisher Resources

ISBN: 9781782161080Supplemental Content