You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Haofeng Tang <ht...@gmail.com> on 2015/03/15 23:07:41 UTC

How to create drill custom functions when 3rd party libraries are needed?

I was able to follow the custom function articles to create new functions.

However, when I tried to create my own test custom functions, where some
3rd party libraries are needed, I wasn't able to get it to work. Here's my
test:

-- Created class "MyClass" in drill-java-exec. Since there're string
operations in this class depending on maven project-A (a 3rd party
library), I added project-A in drill-java.exec dependency list;
-- Built drill;
-- Deployed the target apache-drill-0.8.0-SNAPSHOT.tar.gz;
-- Launched drill, and ran query "select MyClass(string_column) from
my_table"

This gives me an error:

>Query failed: Query stopped., Line 67, Column 58: No applicable
constructor/method found for actual parameters "java.lang.Object";
candidates are: "public void
com.thf.test.Segment.setStart(com.thf.test.Point)" [
3deedeb2-42fa-4fa7-a8a7-4eb802451d58 on localhost:31010 ]

>Error: exception while executing query: Failure while executing query.
(state=,code=0)

where, both com.thf.test.Segment and com.thf.test.Point are classes from
project-A.

Any idea of how to proceed? Suggestion would be appreciated.

Regards

Re: How to create drill custom functions when 3rd party libraries are needed?

Posted by Haofeng Tang <ht...@gmail.com>.
Thanks, that really helps. Not only I had to use fqn on declarations, I
also had to use fqn to explicitly cast objects fetched from list as method
parameters, otherwise exception is thrown for unable to find matching
signature. All works well now. Thanks again!

On Sun, Mar 15, 2015 at 9:56 PM, Jacques Nadeau <ja...@apache.org> wrote:

> Need a little more information to know for sure.  Maybe post of gist of
> your UDF.  Here are some key things for UDFs:
>
> Jar file must include class files AND source files for udf.
> UDF class must be top level class or static inner class and have a no-arg
> constructor.
> UDF must be annotated with function template and use @Param and @Output
> values for input and output.
> @Param and @Outputs must be value holder types.
> References to external classes in UDF must use fully qualified names.
> All dependencies must be on classpath.
>
>
> On Sun, Mar 15, 2015 at 3:07 PM, Haofeng Tang <ht...@gmail.com> wrote:
>
> > I was able to follow the custom function articles to create new
> functions.
> >
> > However, when I tried to create my own test custom functions, where some
> > 3rd party libraries are needed, I wasn't able to get it to work. Here's
> my
> > test:
> >
> > -- Created class "MyClass" in drill-java-exec. Since there're string
> > operations in this class depending on maven project-A (a 3rd party
> > library), I added project-A in drill-java.exec dependency list;
> > -- Built drill;
> > -- Deployed the target apache-drill-0.8.0-SNAPSHOT.tar.gz;
> > -- Launched drill, and ran query "select MyClass(string_column) from
> > my_table"
> >
> > This gives me an error:
> >
> > >Query failed: Query stopped., Line 67, Column 58: No applicable
> > constructor/method found for actual parameters "java.lang.Object";
> > candidates are: "public void
> > com.thf.test.Segment.setStart(com.thf.test.Point)" [
> > 3deedeb2-42fa-4fa7-a8a7-4eb802451d58 on localhost:31010 ]
> >
> > >Error: exception while executing query: Failure while executing query.
> > (state=,code=0)
> >
> > where, both com.thf.test.Segment and com.thf.test.Point are classes from
> > project-A.
> >
> > Any idea of how to proceed? Suggestion would be appreciated.
> >
> > Regards
> >
>



-- 
TANG, Haofeng
htang2000@gmail.com

Re: How to create drill custom functions when 3rd party libraries are needed?

Posted by Jacques Nadeau <ja...@apache.org>.
Need a little more information to know for sure.  Maybe post of gist of
your UDF.  Here are some key things for UDFs:

Jar file must include class files AND source files for udf.
UDF class must be top level class or static inner class and have a no-arg
constructor.
UDF must be annotated with function template and use @Param and @Output
values for input and output.
@Param and @Outputs must be value holder types.
References to external classes in UDF must use fully qualified names.
All dependencies must be on classpath.


On Sun, Mar 15, 2015 at 3:07 PM, Haofeng Tang <ht...@gmail.com> wrote:

> I was able to follow the custom function articles to create new functions.
>
> However, when I tried to create my own test custom functions, where some
> 3rd party libraries are needed, I wasn't able to get it to work. Here's my
> test:
>
> -- Created class "MyClass" in drill-java-exec. Since there're string
> operations in this class depending on maven project-A (a 3rd party
> library), I added project-A in drill-java.exec dependency list;
> -- Built drill;
> -- Deployed the target apache-drill-0.8.0-SNAPSHOT.tar.gz;
> -- Launched drill, and ran query "select MyClass(string_column) from
> my_table"
>
> This gives me an error:
>
> >Query failed: Query stopped., Line 67, Column 58: No applicable
> constructor/method found for actual parameters "java.lang.Object";
> candidates are: "public void
> com.thf.test.Segment.setStart(com.thf.test.Point)" [
> 3deedeb2-42fa-4fa7-a8a7-4eb802451d58 on localhost:31010 ]
>
> >Error: exception while executing query: Failure while executing query.
> (state=,code=0)
>
> where, both com.thf.test.Segment and com.thf.test.Point are classes from
> project-A.
>
> Any idea of how to proceed? Suggestion would be appreciated.
>
> Regards
>