This section guides you through writing and invoking a simple user defined scalar function in Java. It assumes you have downloaded the Aster Execution Engine SQL-Analytics SDK.
To write a user defined function in Java, you create a Java class that implements the following interface:
com.asterdata.ncluster.scalar.ScalarFunction
The class must implement a public constructor that takes:
com.asterdata.ncluster.scalar.ScalarRuntimeContract
The name of your user defined Java function is the name of the Java class, ignoring case differences. So, for example, a function named factorial might be implemented by a Java class com.mycompany.Factorial.
Teradata Aster's SQL-Analytics framework supports one type of scalar function. A user defined scalar function implements the following interface:
- ScalarFunction. ScalarFunction consumes one row as input and returns a single value for each row. From an interface perspective, the function will be passed as an iterator to an arbitrary set of rows. A ScalarFunction consists of:
- the constructor
- the operate function computeValue()