To prepare a Java function for use in SQL-Analytics, compile it into a class file (build it on your workstation) and install it in you Aster instance using the ACT client’s \install command. Be sure to also install any other classes that your function depends on, as we'll explain below.
You must package your SQL-Analytic functions in one of the following ways:
- as a single .class file for the function,
- as a .jar file containing the function class and other classes, or
- as a .zip file containing the function's .jar and other (possibly third-party) .jar files.
The name of the file must match the name of the function. For example, a function named foo must be compiled as Foo.class, and you can install the class on its own or as part of foo.jar, or, finally, as part of foo.zip which contains foo.jar with its Foo.class.
The advantage of a .zip-packaged function is that you can include external .jar files unmodified. For example, you might write a .zip-packaged function with the following structure:
In this example, the primary SQL-Analytics function we care about is "foo," so we package it in an archive called foo.zip, which in turn must contain foo.jar, which in turn must somewhere contain a file Foo.class (path and case are not significant). By using a .zip file, we can contain other classes that our foo function relies on. In this case, the package also contains another class in foo.jar (OtherClass.class) and also another, third-party .jar file (otherjar.jar) with a class that foo relies on, called Useful.class.