JBoss.orgCommunity Documentation
Teiid Designer enables users to extend Teiid's scalar or aggregate function library via modeling and definition of custom or User Defined Functions(UDFs).
The following are used to define a UDF.
Function Name - When you create the function name, keep these requirements in mind:
You cannot overload existing Teiid System functions.
The function name must be unique among user-defined functions in its model for the number of arguments. You can use the same function name for different numbers of types of arguments. Hence, you can overload your user-defined functions.
The function name cannot contain the '.' character.
The function name cannot exceed 255 characters.
Even Pushdown required functions need to be added as a UDF to allow Teiid to properly parse and resolve the function. Pushdown scalar functions differ from normal user-defined functions in that no code is provided for evaluation in the engine. An exception will be raised if a pushdown required function cannot be evaluated by the appropriate source.
Teiid Designer provides a new object wizard to assist in modeling your UDF. Simply right-click select a model and right-click select New > Procedure action. In the wizard there will be an option to specify the functions's jar location on your file system, as well as the java class and java method. (See Section 6.2.2, “Create Relational Procedure Wizard” for further information)
If creating a function by other means, you'll need to select the procedure and edit the different properties for the procedure in the Properties view.
Once you've modeled your functions you can use your function calls in your transformation SQL. These functions will be accessible through the Transformation Editor's expression builder wizard, just like any other built-in function. (See Section 6.3.1.4, “Using the Expression Builder” for further information)
In order for Teiid to become aware of your functions, the actual code must be deployed on your server and available to your Teiid submodule. Your Teiid Designer workspace is aware of any models containing functions and their referenced jars and class info. When a source model containing UDFs is added to a VDB, the jar containing the defined function will be added to your VDB and visible in the VDB Editor's UDF Jars tab.