-Re: How to make a UDF that can take a variable number of arguments while using getArgToFuncMapping?
Thejas M Nair 2011-05-20, 18:41
As a workaround , you can use - MAX(TOBAG(a,b,c));
For example , if a,b,c columns are of type int. Then, TOBAG(a,b,c) will have a schema of bag of integers, and the org.apache.pig.builtin.IntMax class will get used.
On 5/20/11 11:24 AM, "Daniel Dai" <[EMAIL PROTECTED]> wrote:
It is not yet supported. See https://issues.apache.org/jira/browse/PIG-1577
On 05/20/2011 10:42 AM, Jonathan Coveney wrote:
> My goal is to be able to make functions like GREATER(a,b,c...) which can
> take any number of columns, and for each row will give the greater of them.
> I also want to detect what type of columns they are, and use IntGREATER or
> DoubleGREATER or whatever.
> A) has someone done something like this?
> B) If not, how can I specify the correct Schema for getArgToFuncMapping?
> Ideally it could just detect the schema of the first and go off of that, but
> it looks like you have to match it directly... I tried overloading the
> schema GREATER (where getArgTofuncMapping lives) and then using that to
> figure out how many fields there are, but that didn't work. Should this
> approach work? IE is getSchema called before getArgToFuncMapping? Is there a
> cleaner way to do this?
> Thanks for your help!