Scalar and aggregate external C/C++ user-defined functions

Sybase IQ now supports high-performance user-defined functions (UDFs). The UDFs are written in C or C++ code adhering to the interfaces described in the User-Defined Functions Guide. The UDF definitions must be compiled and linked into a shareable library which can then be loaded into a running Sybase IQ server, allowing the UDFs to be used in queries or other SQL statements.

Scalar and aggregate UDFs are only available with the In-database Analytics-Partner Solutions option. Installing the IQ_UDF license enables the scalar and aggregate UDFs.

NoteSybase supports the scalar and aggregate UDF infrastructure only when:

The use of external C/C++ UDFs requires the IQ_UDF license.

Sybase IQ 15.1 includes two types of UDFs—scalar and aggregate:

Scalar Sybase IQ supports simple scalar UDFs that can be used anywhere the SQRT function can be used. These scalar UDFs can be deterministic, which means that for a given set of argument values, the function always returns the same result value, or they can be nondeterministic scalar functions, which means that the same arguments can return different results.

Aggregate Sybase IQ supports external C/C++ user-defined aggregate functions (UDAFs). The SUM function is an example of a built-in aggregate function. You can write UDAFs that can be used anywhere the SUM aggregate can be used. A simple aggregate function produces a single result value from a set of argument values. Many UDAFs can also be used as OLAP-style aggregates with an OVER clause that allows you to specify a static or moving window, within which Sybase IQ computes the aggregate. See Chapter 2, “Using OLAP,” in System Administration Guide: Volume 2.

Note that these new external C/C++ UDFs are different than the Interactive SQL UDFs, introduced in earlier versions of Sybase IQ. Interactive SQL UDFs are unchanged in version 15.1, and do not require a special license. Documentation on creating UDFs using Interactive SQL remains in its original location: Chapter 1, “Using Procedures and Batches,” in System Administration Guide: Volume 2.

For more information on scalar and aggregate UDFs, see the User-Defined Functions Guide.