Adding New Packages to Existing Script Languages

This section explains how to expand existing script languages with additional packages or libraries using BucketFS.

The Lua script language is not expandable and is natively compiled into the Exasol database software.

Script Language Container

A script language container consists of a Linux container with a complete Linux distribution and all required libraries. You can install the libraries and other dependencies to a script language container with the usual package manager, such as apt-get or pip. This simplifies the installation of packages with many dependencies.

Exasol provides different flavors of script language containers for Python 2 and 3, R, and Java on GitHub. A flavor is essentially a build description that contains a number of files and a description of how they are connected. We also provide various packages for these languages. You can use one of our pre-built containers or extend one of our flavors with additional packages and build your container.

Using a Pre-built Script Language Container

Customizing an Existing Container

You can build a customized script language container with the libraries that you need. The easiest way to do this is by using exaslct, which is available on our GitHub. Exasol also uses exaslct to build the pre-built containers.

Using exaslct you can build a new container from a build description that we call flavor. A flavor contains a number of Docker files and a description of how they are connected. For all flavors, we also provide a dedicated mechanism to customize them. After you customize and build your container, the rest of the installation procedure is the same as for our pre-built containers.

For more details, see script-languages-release on GitHub.

Script Languages Developer Sandbox

Exasol provides virtual machine images that can be used as a developer sandbox to easily build script language containers. The virtual machine image provides:

  • The script-languages-release repositories

  • All necessary dependencies to execute exaslct in script-languages-release (including a correctly configured docker runtime)

  • A running Jupyterlab instance that is automatically started when the vm boots

For more information and downloads, see the Script-Languages-Developer-Sandbox User Guide on GitHub.

Adding Java files (.jar) to a Java UDF

As an alternative to adding a new script language container, you can specify required JAR-Files in a Java UDF via there BucketFS Path.

If you for instance want to use Google's library to process telephone numbers, you could upload the file similarly to the examples above in the bucket named javalib. The corresponding local bucket path would look like the following: /buckets/bfsdefault/javalib/libphonenumber-4.2.jar.

In the following script, you can see how the path is configured to import the library.

--/
CREATE JAVA SCALAR SCRIPT jphone(num VARCHAR(2000))
RETURNS VARCHAR(2000) AS
%jar /buckets/bfsdefault/javalib/libphonenumber-4.2.jar;
 
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
class JPHONE {
  static String run(ExaMetadata exa, ExaIterator ctx) throws Exception {
    PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
    try {
      PhoneNumber swissNumberProto = phoneUtil.parse(ctx.getString("num"),
                            "DE");
      return swissNumberProto.toString();  
    } catch (NumberParseException e) {
      System.err.println("NumberParseException thrown: " + e.toString());
    }
    return "failed";
  }
}
/

See also: