Hi Charles,

yes you can. For example, you can create my.txt in your jar resource folder.
>From code you may load its content using:
getClass().getClassLoader().getResourceAsStream("my.txt").
But this will work only for functions loaded during drillbit startup (when
you add jars in drillbit classpath).
Won't work for dynamically loaded functions, since these functions have
custom classloader.

Kind regards
Arina


On Mon, Jan 30, 2017 at 5:18 PM, Charles Givre <[email protected]> wrote:

> Hi Arina,
> Thank you very much for taking a look.  I actually got it to work last
> night and found that the cause of the error was that I was not initializing
> the @Workspace parameters correctly.
> I had another question which I was wondering if you might be able to
> assist with.  I’m not a Java developer by trade so forgive me if this is a
> total n00b question, but obviously, I don’t want to hard-code the path to
> that database.  Is there an easy way that I can include it the resources
> file, have it bundled with the JAR and then include a relative path, or
> something like that?
> Thanks,
> — C
>
>
>
> > On Jan 30, 2017, at 05:25, Arina Yelchiyeva <[email protected]>
> wrote:
> >
> > Hi Charles,
> >
> > 1. drill-module.conf: should be the following:
> > *drill.classpath.scanning.packages
> > += "org.apache.drill.contrib.function"*
> > 2. when I have built the jars and tried to register functions, I got the
> > following error: org.apache.drill.common.exceptions.
> DrillRuntimeException:
> > Unexpected class load failure while attempting to load Function Registry
> > (com.maxmind.geoip2.DatabaseReader), so I have copied two jars into
> > <drill>/jars
> > folder: maxmind-db-1.2.1.jar and geoip2-2.8.0.jar and function seems to
> > work fine (well, could not read DB but it's expected since you have
> > hard-coded your local path in your function code: java.io.File database =
> > new
> > java.io.File("/Users/cgivre/OneDrive/github/drillworkshop/
> GeoLite2/GeoLite2-City.mmdb");).
> > I guess these jars should be present in drill classpath at startup
> despite
> > the the way you register functions (dynamic or not).
> >
> > 0: jdbc:drill:zk=local> create function using jar
> > 'drill-geoip-functions-1.0.jar';
> > +----+---------+
> > | ok | summary |
> > +----+---------+
> > | true | The following UDFs in jar drill-geoip-functions-1.0.jar have
> been
> > registered:
> > [getcountryname(VARCHAR-OPTIONAL), getcityname(VARCHAR-REQUIRED)] |
> > +----+---------+
> > 1 row selected (1.083 seconds)
> >
> > 0: jdbc:drill:zk=local> select getCityName('A') from sys.version;
> > IOException encountered:  Could not read MaxMind DBIOException
> encountered:
> > Could not read MaxMind DB+----------+
> > |  EXPR$0  |
> > +----------+
> > | Unknown  |
> > +----------+
> >
> >
> > Kind regards
> > Arina
> >
> >
> > On Sun, Jan 29, 2017 at 2:41 AM, Charles Givre <[email protected]> wrote:
> >
> >> HI Arina,
> >> I’m still getting weird errors.
> >>
> >> Here’s my UDF: https://github.com/cgivre/drill-geoip-functions <
> >> https://github.com/cgivre/drill-geoip-functions>
> >>
> >> I build it using: mvn clean package -DskipTests and it builds fine.  I
> >> copy the .jar files it creates to <drill>/jars/3rdparty, but when I try
> to
> >> execute a query, I get:
> >>
> >> Query Failed: An Error Occurred
> >> org.apache.drill.common.exceptions.UserRemoteException: VALIDATION
> ERROR:
> >> From line 1, column 19 to line 1, column 42: No match found for function
> >> signature getCityName() SQL Query null [Error Id:
> deb83448-db82-4351-b95d-f183c25efb0b
> >> on charless-mbp-2.fios-router.home:31010]
> >>
> >> Would you mind taking a quick look at my code?  I have a feeling this is
> >> something simple and obvious, like a wrong path somewhere.  I’ve written
> >> other UDFs before and gotten them to work, so I’m a little stuck.
> >> Thanks,
> >> — Charles
> >>
> >>
> >>
> >>> On Jan 28, 2017, at 08:22, Arina Yelchiyeva <
> [email protected]>
> >> wrote:
> >>>
> >>> Hi Charles,
> >>>
> >>> drill-module.conf file should be placed in src/main/resources folder.
> >>> Example:
> >>> https://github.com/arina-ielchiieva/drillUDF/blob/
> >> master/src/main/resources/drill-module.conf
> >>>
> >>>
> >>> Kind regards
> >>> Arina
> >>>
> >>> On Fri, Jan 27, 2017 at 10:50 PM, Charles Givre <[email protected]>
> >> wrote:
> >>>
> >>>> I’m having some trouble registering a UDF I wrote.  The UDF was
> working
> >> in
> >>>> previous versions of Drill and now Drill doesn’t seem to recognize it.
> >>>> When I try to register it I get the following error:
> >>>>
> >>>> : jdbc:drill:zk=local> create function using jar
> >>>> 'drill-geoip-functions-1.0.jar';
> >>>> +--------+--------------------------------------------------
> >> -------------+
> >>>> |   ok   |                            summary
> >>  |
> >>>> +--------+--------------------------------------------------
> >> -------------+
> >>>> | false  | Jar drill-geoip-functions-1.0.jar does not contain
> >> functions  |
> >>>> +--------+--------------------------------------------------
> >> -------------+
> >>>>
> >>>> I do have a drill-module.conf file and here are the contents:
> >>>> drill.classpath.scanning.packages += "org.apache.drill.contrib.
> >> function"
> >>>> I tried moving this file around and I put a copy in the /src folder as
> >>>> well as the /src/main folder to no avail.  Any suggestions?
> >>>> Thanks,
> >>>> — Charles
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>
> >>
>
>

Reply via email to