Grokbase Groups Hive user July 2010
You can use the GenericUDF option (rather than the reflective option) to avoid duplicating code. For an example, see GenericUDFIf, which implements the if(cond,expr1,expr2) expression.

On Jul 19, 2010, at 1:26 PM, Mark Tozzi wrote:

Hi All,

I've been working with UDFs in hive a lot lately, usually to implement
some manner of small lookup which isn't worth the overhead of a join,
or which for some other reason is preferable as a function as a join.
This gets me into situations where I end up wanting one UDF to have
multiple return types - for example something like a geo IP look-up
would return an integer for an area code look-up or a string for a
country name look-up. It seems the two ways to handle this are to
either write a different UDF for each return type, or potentially each
look-up, or to always return a String and use the hive built in cast
function "cast(expr as <type>)" on the return value. So far I've been
favoring the second as the first seems to lead to a proliferation of
nearly identical classes, but I'm wondering if someone with more
experience in this might have a suggestion as why one might be better
than the other, or indeed if there is a third solution that I have


--Mark Tozzi

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 4 | next ›
Discussion Overview
groupuser @
categorieshive, hadoop
postedJul 19, '10 at 8:28p
activeJul 19, '10 at 10:10p



site design / logo © 2021 Grokbase