User-defined extensions

A user-defined extension (UDX) is a function, created by you or by a third party, to augment the set of built-in functions that are provided by a Db2® instance.

This capability is supported in the following environments:
Table 1. Support for UDXs
  C++ Lua
Integrated Analytics System yes yes
IBM® Db2 Warehouse on IBM POWER LE and Intel x86 hardware yes yes
IBM Db2 Warehouse on all other supported hardware    
IBM Db2 Warehouse on Cloud (enterprise plans) yes  
IBM Db2 on Cloud    

A Db2 instance provides built-in functions such as sqr() and length() that calculate values based on input arguments. A user-defined extension (UDX) is a custom function created to satisfy special data querying or business reporting needs that are not covered by the built-in functions. For example, you might create a function that carries out data conversion or that provides a new and unique type of analysis.

A UDX can be written in any of the following languages:
  • C++
  • Lua
  • Python
  • R

After a UDX is deployed, the person who deployed it and any administrator can use the UDX immediately. An administrator can also share a UDX with other users; only then can these other users use the UDX.

You invoke a UDX in an SQL statement in the same way that you would invoke a built-in function. A UDX can accept zero or more input values but produces one output value. Input values to a UDX can be literals, column references, or expressions. The data types of inputs and output must be built-in (that is, not customized) data types.