Adding New Packages to Existing Script Languages

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

You can skip this section if Exasol's pre-configured script languages are sufficient for your requirements.

You can further expand the existing script languages by adding more packages to it. The procedures are different for every language.

The script language Lua is not expandable, and it 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.

Furthermore, on GitHub, we provide several flavors of script language containers with support for Python 2/3, R, Java, and various packages for these languages. You can use either 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

This section provides you with information on how to use one of our pre-built containers.

Customizing an Existing Container

Besides our pre-built script language container, you can also build a customized container with libraries you need. The easiest way to do this is by using exaslct from our GitHub. Exasol uses exaslct to build the pre-built container as well.

Using exaslct builds a new container from a build description which we call flavor. A flavor contains mainly a bunch of Docker files and a description of how they are connected. Additionally, for all the flavors, we also provide a dedicated mechanism to customize them. For a detailed description, please refer to the description in our GitHub. After you customize and build your container, the rest of the installation procedure is the same as our pre-built containers.

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: