You can translate the document:

How to develop a Virtual DataPort Custom Function

Developing a Virtual DataPort Custom Function

As a next step, let's move on to developing a Virtual DataPort Custom function in which you can extend the set of functions available in Denodo Virtual DataPort.


Virtual DataPort Functions

In order to see the list of existing functions, you can open the dialog Help > Functions list in your Virtual DataPort Administration Tool:


Implementing new Virtual DataPort Functions

Custom functions are implemented as Java classes included in a Jar file that is added to Virtual DataPort as extension. There are some general rules to keep in mind before developing these functions, you can refer the section Developing Custom Functions for more details on it.

You could create a Custom function by using "annotations" or following some "name conventions". We will use the first approach as it is the recommended one!.


Now let’s learn how to develop a StringConcatenate function which would join two or more strings together!


  1. Launch Eclipse, create a new project by navigating to File> New > Project:
  2. Create a new Denodo Extension project by choosing Denodo4E > Denodo Extension project and click on
    Next >.
  3. Specify the project name as my_denodo_extensions and click Next >:
  4. Select the path to your local Denodo Platform installation.

  5. Choose Denodo VDP/ITP Server as Denodo application and Denodo VDP Custom Function as Extension configuration.

  6. Enter the package, e.g. com.denodo.vdp.custom.functions, and the Java class name, e.g. StringConcatenate and Click Finish.
  7. Now you could see that file gets created in the Package Explorer and the needed dependencies get imported to the project classpath:
  8. When you double-click on the file, you will see a template to implement the Virtual DataPort Custom Function (it is automatically created). This template consists of a simple function returning the length of an input String.

    As you can see the java class contains several annotations to indicate Virtual DataPort the following:
    • @CustomElement(type=CustomElementType.VDPFUNCTION, name="STRINGCONCATENATE"): the Java class contains the code of a Virtual DataPort custom function called STRINGCONCATENATE.
    • @CustomExecutor: method containing the code that Virtual DataPort will have to run when the custom function is invoked.
    • @CustomParam(name = "s") String s: input parameters definition (Note: See the equivalency table between Java and Virtual DataPort data types).
    • @CustomExecutorReturnType: method invoked by Virtual DataPort to obtain the return type of the custom function.

  9. For implementing the new function you only have to modify the Java code of this function:

    You could find the Java class of this StringConcatenate custom function in this link.




Deploy our Custom Function into Virtual DataPort

Ok, once the function is ready it's time to deploy it into Virtual DataPort (it has to be launched before you deploy the extension!). The Denodo4e plugin allows to deploy the extensions created in the Eclipse project. You only have to follow these steps:

  1. Right click on the project my_denodo_extensions and select Deploy Extensions:
  2. Provide the connection details to the Virtual DataPort server in the Denodo VDP/ITP server configuration section and the metadata information of the extension you are going to deploy: JAR name, description, version, target Denodo version and update and click Finish.
  3. From your Virtual DataPort Administration tool, first click on File > Refresh to load the changes. Then navigate to File > Extension Management, you will find a new extension!
  4. You could see the jar extension denodo-tutorial-extensions was added. Also you can check the dialog Help > Functions list to see the new function (with the syntax defined in the @CustomExecutor annotation!).
  5. Finally, you can test the new function, for example, from the VQL Shell:

If you want to debug your custom function, take a look at the Denodo4e User Guide. It includes useful information for using the Debug functionality of Eclipse.


I want to know more advanced techniques!

Is it possible to have different signatures for the same custom function?

Yes, you only have to add more methods having the @CustomExecutor annotation, for example:

public Integer method1(Integer i) { ... }
public Integer method2(Integer i, String s) { ... }

Could my custom function be delegated to a JDBC data source?

Yes, you only have to configure the @CustomExecutor annotation adding the delegation pattern, for example:

 @CustomExecutor(implementation = true, delegationPatterns = {
             @DelegationPattern(databaseName = "sqlserver",
                                pattern = "CONCAT($0[, $i]{1, n})") })
In that example Virtual DataPort will delegate the execution of the function to SQL Server (using the CONCAT() function of SQL Server), whenever it is possible. If a different data source in envolved in the query then Virtual DataPort will execute the code implemented in the custom function instead of delegating it. Find more examples here.


That's all! You have created your first custom fucntion. You can now click on the NEXT> button to continue with this tutorial.

Add feedback