Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> can i define an udf which can process more than one argument?


Copy link to this message
-
Re: can i define an udf which can process more than one argument?
Hi Chris,

Of course it is possible to write UDF with as many parameters as you want,
even with variable number of arguments. Have a look at the nice article
from Mark Grover [1] about writing UDFs. It also contains link to a
real-life example [2].

Best regards,
Jan Dolinar

[1] http://mark.thegrovers.ca/1/post/2012/06/how-to-write-a-hive-udf.html
[2]
https://github.com/markgrover/hive-translate/blob/master/GenericUDFTranslate.java

On Fri, Oct 19, 2012 at 5:36 AM, Chris Gong <[EMAIL PROTECTED]> wrote:

> **
> i find that UDF can only process one argument like
>    public long evaluate(String ip) {
>
>   }
>
> can i define a udf like  COALESCE(T v1, T v2, …) or  if(boolean
> testCondition, T valueTrue, T valueFalseOrNull)?
>
> ------------------------------
> Chris Gong
>