Hi again Nirav, Yup that looks like Drill just isn't finding the function. Do you have a '/src/main/resources/drill-module.conf' file set up in your Maven project for the UDF? If so, could you paste the text here?
Best, Nathan On Thu, Jan 7, 2016 at 11:03 PM, Nirav Shah <[email protected]> wrote: > Sorry for delayed response. > > @Abdel, > I have put both jars in 3rdparty jars. My other UDFs are working fine. > > @Nathan > I tried this still same issue. > > May be I am doing some silly mistake. > > *Complete Code :* > > package com.games24x7.drill; > > import java.util.Date; > > import javax.inject.Inject; > > import org.apache.drill.exec.expr.DrillSimpleFunc; > import org.apache.drill.exec.expr.annotations.FunctionTemplate; > import org.apache.drill.exec.expr.annotations.Output; > import org.apache.drill.exec.expr.annotations.Param; > import org.apache.drill.exec.expr.holders.IntHolder; > import org.apache.drill.exec.expr.holders.NullableVarCharHolder; > import org.apache.drill.exec.expr.holders.VarCharHolder; > > import io.netty.buffer.DrillBuf; > import net.sourceforge.wurfl.core.Device; > import net.sourceforge.wurfl.core.EngineTarget; > > @FunctionTemplate(name = "GetBrowserDtl", scope = > FunctionTemplate.FunctionScope.SIMPLE, nulls = > FunctionTemplate.NullHandling.NULL_IF_NULL) > public class BrowserFuncNew implements DrillSimpleFunc { > > @Param > NullableVarCharHolder userAgent; > @Param > IntHolder option; > @Output > VarCharHolder outValue; > @Inject > DrillBuf buffer; > @Inject > net.sourceforge.wurfl.core.GeneralWURFLEngine wurfl; > public void setup() { > // TODO Auto-generated method stub > //wurfl = new > net.sourceforge.wurfl.core.GeneralWURFLEngine("wurfl.xml"); > } > > public void eval() { > String stringOutValue = "null"; > > try { > wurfl = new > net.sourceforge.wurfl.core.GeneralWURFLEngine("/home/nirav/wurfl.xml"); > // String SUA = > org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(userAgent.start, > userAgent.end, userAgent.buffer); > > > /* String[] capabilities = { > "device_os", > "device_os_version", > "is_tablet", > "is_wireless_device", > "pointing_method", > "preferred_markup", > "resolution_height", > "resolution_width", > "ux_full_desktop", > "xhtml_support_level", > "is_smarttv", > "can_assign_phone_number", > "brand_name", > "model_name", > "marketing_name", > "mobile_browser_version" > }; > wurfl.setEngineTarget(EngineTarget.accuracy); > wurfl.setCapabilityFilter(capabilities); > Device device = wurfl.getDeviceForRequest(SUA); > System.out.println("4-->"+new Date( > System.currentTimeMillis())); > System.out.println("Device OS: " + > device.getCapability("device_os")); > System.out.println("Device OS version: " + > device.getCapability("device_os_version")); > System.out.println("Brand name: " + > device.getCapability("brand_name")); > System.out.println("advertised_device_os_version: " + > device.getCapability("advertised_device_os_version")); > System.out.println("advertised_device_os: " + > device.getCapability("advertised_device_os")); > System.out.println("advertised_browser: " + > device.getCapability("advertised_browser")); > > System.out.println("advertised_browser_version:"+device.getCapability("advertised_browser_version")); > stringOutValue = device.getCapability("device_os_version"); > */ > byte[] valueDecoded = stringOutValue.getBytes(); > outValue.buffer = buffer.reallocIfNeeded(valueDecoded.length); > outValue.start = 0; > outValue.end = valueDecoded.length; > buffer.setBytes(0, valueDecoded); > } catch (Exception e) { > // TODO Auto-generated catch block > //stringOutValue = "null6"; > byte[] valueDecoded = e.getMessage().getBytes(); > outValue.buffer = buffer.reallocIfNeeded(valueDecoded.length); > outValue.start = 0; > outValue.end = valueDecoded.length; > buffer.setBytes(0, valueDecoded); > > } > > } > } > // select GetBrowserDtl('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 > (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36',1) from (values(1)); > //select GetBrowserDtl('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) > Gecko/20100101 Firefox/31.0',1) from (values(1)); > //select GetBrowserDtl('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) > Gecko/20100101 Firefox/31.0',1) from (values(1)); > > *Result:* > > 0: jdbc:drill:zk=local> select GetBrowserDtl('Mozilla/5.0 (X11; Linux > x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 > Safari/537.36',1) from (values(1)); > Jan 08, 2016 12:14:17 PM > org.apache.calcite.sql.validate.SqlValidatorException <init> > SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: No match > found for function signature GetBrowserDtl(<CHARACTER>, <NUMERIC>) > Jan 08, 2016 12:14:17 PM org.apache.calcite.runtime.CalciteException <init> > SEVERE: org.apache.calcite.runtime.CalciteContextException: From line 1, > column 8 to line 1, column 130: No match found for function signature > GetBrowserDtl(<CHARACTER>, <NUMERIC>) > Error: VALIDATION ERROR: From line 1, column 8 to line 1, column 130: No > match found for function signature GetBrowserDtl(<CHARACTER>, <NUMERIC>) > > > [Error Id: 5a8c24d3-1b26-4dfd-be6d-615ba051ad1c on nirav:31010] > (state=,code=0) > > > On Thu, Jan 7, 2016 at 2:55 AM, Nathan Griffith <[email protected]> > wrote: > >> Hi Nirav! >> >> A couple thoughts: a.) To help troubleshoot, you may want to prepend >> the full path of "wurfl.xml" in the first statement of your code, b.) >> So when you try to use the UDF in a query you get absolutely no error >> messages from Drill? >> >> Also, the first part of this article >> ( >> http://www.dremio.com/blog/querying-google-analytics-json-with-a-custom-sql-function/ >> ) >> makes a good resource for telling Drill how to pick up on a new UDF. >> >> Best, >> Nathan >> >> On Wed, Jan 6, 2016 at 10:23 AM, Abdel Hakim Deneche >> <[email protected]> wrote: >> > According to Drill documentation: >> > >> > http://drill.apache.org/docs/adding-custom-functions-to-drill/ >> > >> > You need to copy both class jar and source jar of your UDF to >> > $DRILL_HOME/jars/3rdparty/ >> > >> > did you do it ? >> > >> > On Tue, Jan 5, 2016 at 11:58 PM, Nirav Shah <[email protected]> >> > wrote: >> > >> >> Hi , >> >> >> >> >> >> I am trying to extract info from user agent using WURFL libraries. >> >> >> >> I am not sure what's wrong I am doing here but it's not working and not >> >> giving any errors as well. >> >> >> >> I have put wurfl.xml in source folder and wurfl<version>.jar to >> >> /jar/3rdparty/ >> >> >> >> *Code :* >> >> >> >> wurfl = new >> >> net.sourceforge.wurfl.core.GeneralWURFLEngine("wurfl.xml"); >> >> String SUA = >> >> >> >> >> org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(userAgent.start, >> >> userAgent.end, userAgent.buffer); >> >> >> >> >> >> String[] capabilities = { >> >> "device_os", >> >> "device_os_version", >> >> "is_tablet", >> >> "is_wireless_device", >> >> "pointing_method", >> >> "preferred_markup", >> >> "resolution_height", >> >> "resolution_width", >> >> "ux_full_desktop", >> >> "xhtml_support_level", >> >> "is_smarttv", >> >> "can_assign_phone_number", >> >> "brand_name", >> >> "model_name", >> >> "marketing_name", >> >> "mobile_browser_version" >> >> }; >> >> wurfl.setEngineTarget(EngineTarget.accuracy); >> >> wurfl.setCapabilityFilter(capabilities); >> >> Device device = wurfl.getDeviceForRequest(SUA); >> >> System.out.println("4-->"+new Date( >> >> System.currentTimeMillis())); >> >> System.out.println("Device OS: " + >> >> device.getCapability("device_os")); >> >> System.out.println("Device OS version: " + >> >> device.getCapability("device_os_version")); >> >> System.out.println("Brand name: " + >> >> device.getCapability("brand_name")); >> >> System.out.println("advertised_device_os_version: " + >> >> device.getCapability("advertised_device_os_version")); >> >> System.out.println("advertised_device_os: " + >> >> device.getCapability("advertised_device_os")); >> >> System.out.println("advertised_browser: " + >> >> device.getCapability("advertised_browser")); >> >> >> >> >> >> >> System.out.println("advertised_browser_version:"+device.getCapability("advertised_browser_version")); >> >> stringOutValue = device.getCapability("device_os_version"); >> >> >> >> >> >> Regards, >> >> Nirav >> >> >> > >> > >> > >> > -- >> > >> > Abdelhakim Deneche >> > >> > Software Engineer >> > >> > <http://www.mapr.com/> >> > >> > >> > Now Available - Free Hadoop On-Demand Training >> > < >> http://www.mapr.com/training?utm_source=Email&utm_medium=Signature&utm_campaign=Free%20available >> > >>
