Custom Function - How To call from VDP

HI, I have denodo 6.0 with custom function public class ASB_VdpFunction { @CustomExecutor(syntax = "normsdist(double x): double") public double normsdist( Double x ) { return 0.01;} } I compile and generate jar and load using Jar Management. When I try to call from VQL shell: Select normsdist (0.4343); But receive: Finished with error: Function 'normsdist' with arity 1 not found Do I need to restart the VDP server? what's the correct way to call custom function? Any example?
user
13-01-2018 04:01:22 -0500

1 Answer

Hi, You don't need to restart the server. And your sample select statement is syntactically valid. However, I see two minor issues you should take a look at to get this working. First, the name of your function doesn't derive from the name of the method that you define at the *@CustomExecutor* annotation. Above the opening line of your *ASB_VdpFunction* class, you should have a *@CustomElement* annotation that defines the class as a VDPFUNCTION and what name it will use. For example, to name your function *normsdist* as you'd intended, you'd need to declare it like this; `@CustomElement(type=CustomElementType.VDPFUNCTION, name="normsdist")` If you use the [Denodo4e](https://community.denodo.com/docs/html/browse/6.0/vdp/developer/developing_extensions/developing_extensions) extension for Eclipse, it will prepopulate the annotations you will need. The executor method can be named anything, by the way. When you import the JAR via Jar Management, you should see a confirmation of the name of your function(s) based on the @CustomElement annotations. Second, custom Denodo functions need to return an object, not a primitive. I'd update that method type from *double* to *Double*. What you have will compile and import, but won't be listed as an available function due to the data type. Note that to overwrite a previously imported JAR, you need to first **Delete** the JAR from Jar Management, then **Create** it again. Hope this helps!
Denodo Team
17-01-2018 12:02:23 -0500
You must sign in to add an answer. If you do not have an account, you can register here