thiru_k
thiru_k

Reputation: 847

Creating and using UDF in Hive

I created UDF as mentioned in http://www.findnwrite.com/musings/extract-top-n-records-in-each-group-in-hadoophive/

After executing statement "create temporary function rank as 'com.example.hive.udf.Rank';" I get the log as shown in http://pastebin.com/hHFa9G9A

How do I interpret the log or how do I know whether function is created successfully?

Also when I execute the hive query using the function rank I get the exception as described in http://pastebin.com/fP5LnyGG

Upvotes: 0

Views: 3118

Answers (1)

thiru_k
thiru_k

Reputation: 847

This issue is solved

Couple of bugs in the article itself http://www.findnwrite.com/musings/extract-top-n-records-in-each-group-in-hadoophive/

Replaced the statements in the article with below statements

1)

Create Rank jar


jar -cf Rank.jar ./com/example/hive/udf/Rank.class

2)

SELECT user, category, value
FROM (
    SELECT user, category, rank(user) as rank, value
    FROM $compTable
    WHERE user is NOT NULL AND AND ctr > 0
    DISTRIBUTE BY user
    SORT BY user, value desc
) a
WHERE rank(user) < 5
ORDER BY user, rank(user)

Upvotes: 1

Related Questions