hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leena Gupta <>
Subject Hive UDF error
Date Thu, 15 May 2014 18:07:42 GMT

I'm trying to create a function that generates a UUID, want to use it in a
query to insert data into another table.

Here is the function:

package com.udf.example;

import  java.util.UUID;
import org.apache.hadoop.hive.ql.exec.Description;
import  org.apache.hadoop.hive.ql.exec.UDF;

name = "Uuid",
value = "_FUNC_() - Generate a unique uuid",
extended="Select Uuid from foo limit 1;"

class Uuid extends UDF{
  public Text evaluate(){
    return new Text(UUID.randomUUID().toString());

I registered it successfully in Hive but when I try to use it in a query I
get a Nullpointer exception(see below). The same function when I run
outside of Hive by including main() is able to return a UUID.
Could someone please help shed some light on why I'm getting this error.

select entity_volume,Uuid() from test_volume limit 5;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201311092117_0312, Tracking URL =
Kill Command = /usr/lib/hadoop/bin/hadoop job  -Dmapred.job.tracker= -kill job_201311092117_0312
Hadoop job information for Stage-1: number of mappers: 1; number of
reducers: 0
2014-05-15 10:12:10,825 Stage-1 map = 0%,  reduce = 0%
2014-05-15 10:12:29,916 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201311092117_0312 with errors
Error during job, obtaining debugging information...
Examining task ID: task_201311092117_0312_m_000002 (and more) from job
Exception in thread "Thread-23" java.lang.NullPointerException
FAILED: Execution Error, return code 2 from
MapReduce Jobs Launched:
Job 0: Map: 1   HDFS Read: 0 HDFS Write: 0 FAIL


View raw message