You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by Yash Sharma <ya...@gmail.com> on 2014/05/09 15:15:15 UTC

Quick question on Drill Func parameters

I am trying to implement a reflect UDF for allowing drill to use java
methods directly:
https://issues.apache.org/jira/browse/DRILL-345

I would be used like:

SELECT reflect("java.lang.String", "valueOf", 1),
       reflect("java.lang.String", "isEmpty"),
       reflect("java.lang.Math", "max", 2, 3),
       reflect("java.lang.Math", "min", 2, 3),
       reflect("java.lang.Math", "round", 2.5),
       reflect("java.lang.Math", "exp", 1.0),
       reflect("java.lang.Math", "floor", 1.9)FROM src LIMIT 1;

1   true    3   2   3   2.7182818284590455  1.0



So, while the first 2 params would be strings, there can be any number of
parameters following them.

How to I pass variable length arguments to any Drill Function?
Is something similar to this being done anywhere in the code?

Peace,
Yash

Re: Quick question on Drill Func parameters

Posted by Yash Sharma <ya...@gmail.com>.
Sounds good. Thanks lot Steven.

Peace,
Yash


On Tue, May 13, 2014 at 1:03 AM, Steven Phillips <sp...@maprtech.com>wrote:

> I don't think there is a way to provide variable number of inputs to a
> drill func currently.
> An easy way to make this work would be to include all of the parameters as
> a single string, separated by some delimiter, and then split the string
> into tokens.
>
>
> On Fri, May 9, 2014 at 6:15 AM, Yash Sharma <ya...@gmail.com> wrote:
>
> > I am trying to implement a reflect UDF for allowing drill to use java
> > methods directly:
> > https://issues.apache.org/jira/browse/DRILL-345
> >
> > I would be used like:
> >
> > SELECT reflect("java.lang.String", "valueOf", 1),
> >        reflect("java.lang.String", "isEmpty"),
> >        reflect("java.lang.Math", "max", 2, 3),
> >        reflect("java.lang.Math", "min", 2, 3),
> >        reflect("java.lang.Math", "round", 2.5),
> >        reflect("java.lang.Math", "exp", 1.0),
> >        reflect("java.lang.Math", "floor", 1.9)FROM src LIMIT 1;
> >
> > 1   true    3   2   3   2.7182818284590455  1.0
> >
> >
> >
> > So, while the first 2 params would be strings, there can be any number of
> > parameters following them.
> >
> > How to I pass variable length arguments to any Drill Function?
> > Is something similar to this being done anywhere in the code?
> >
> > Peace,
> > Yash
> >
>
>
>
> --
>  Steven Phillips
>  Software Engineer
>
>  mapr.com
>

Re: Quick question on Drill Func parameters

Posted by Steven Phillips <sp...@maprtech.com>.
I don't think there is a way to provide variable number of inputs to a
drill func currently.
An easy way to make this work would be to include all of the parameters as
a single string, separated by some delimiter, and then split the string
into tokens.


On Fri, May 9, 2014 at 6:15 AM, Yash Sharma <ya...@gmail.com> wrote:

> I am trying to implement a reflect UDF for allowing drill to use java
> methods directly:
> https://issues.apache.org/jira/browse/DRILL-345
>
> I would be used like:
>
> SELECT reflect("java.lang.String", "valueOf", 1),
>        reflect("java.lang.String", "isEmpty"),
>        reflect("java.lang.Math", "max", 2, 3),
>        reflect("java.lang.Math", "min", 2, 3),
>        reflect("java.lang.Math", "round", 2.5),
>        reflect("java.lang.Math", "exp", 1.0),
>        reflect("java.lang.Math", "floor", 1.9)FROM src LIMIT 1;
>
> 1   true    3   2   3   2.7182818284590455  1.0
>
>
>
> So, while the first 2 params would be strings, there can be any number of
> parameters following them.
>
> How to I pass variable length arguments to any Drill Function?
> Is something similar to this being done anywhere in the code?
>
> Peace,
> Yash
>



-- 
 Steven Phillips
 Software Engineer

 mapr.com