Uploaded image for project: 'Solution Center'
  1. Solution Center
  2. SOL-201

Using arbitrary JAR (Java Archive) libraries within UDFs (User Defined Functions)

    XMLWordPrintable

    Details

    • Type: How To
    • Status: Published
    • Affects Version/s: EXASolution 5.0.2, EXASOL 6.0.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      You have an own jar you want to use within Java UDFs.
      Requirements:
      * a license which includes the extra database feature called "Java"
      * a (temporary) ftp/http server with your jar file
    • Solution:
      Hide

      For testing purposes, you can use my-app-1.0-SNAPSHOT.jar.
      This jar was generated using the following tutorial:
      http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

      Steps:
      1. Install the jar library:

      • EXASOL 5 or before: Use EXAoperation like in java_udf.jpg.
      • EXASOL 6 or later: See detailed information about EXABucket FS in SOL-503 and in particular the subsection Expanding script languages using BucketFS in the EXASOL user manual. There you can see, how to adapt java_udf.sql to import java libraries from buckets.

      2. Adapt the java_udf.sql if you are using EXASOL 6 or later
      3. Run java_udf.sql. Please keep the following in mind:

      • EXASOL 5 or before only: The jar name is different now, it is the name you chose in EXAoperation + ".jar" (here: "myapp.jar")
      • The script and the class name must be equal respecting case sensitivity (here: "HELLOWORLD")
      • If you have a scalar script, the return type of the script (here: "VARCHAR(200)") must correspond to the return type of the run method of the class (here: "String")
      • If you have an emits script, the return type of the run method is void and you must use the method ExaIterator.emit of your ExaIterator instance (here: "ctx")
      Show
      For testing purposes, you can use my-app-1.0-SNAPSHOT.jar . This jar was generated using the following tutorial: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html Steps: 1. Install the jar library: EXASOL 5 or before: Use EXAoperation like in java_udf.jpg . EXASOL 6 or later: See detailed information about EXABucket FS in SOL-503 and in particular the subsection Expanding script languages using BucketFS in the EXASOL user manual. There you can see, how to adapt java_udf.sql to import java libraries from buckets. 2. Adapt the java_udf.sql if you are using EXASOL 6 or later 3. Run java_udf.sql . Please keep the following in mind: EXASOL 5 or before only: The jar name is different now, it is the name you chose in EXAoperation + ".jar" (here: "myapp.jar") The script and the class name must be equal respecting case sensitivity (here: "HELLOWORLD") If you have a scalar script, the return type of the script (here: "VARCHAR(200)") must correspond to the return type of the run method of the class (here: "String") If you have an emits script, the return type of the run method is void and you must use the method ExaIterator.emit of your ExaIterator instance (here: "ctx")
    • Category 1:
      Cluster Administration - BucketFS
    • Category 2:
      UDFs and In-Database Analytics

      Attachments

        Issue Links

        1. java_udf.jpg
          java_udf.jpg
          61 kB
        2. java_udf.sql
          0.6 kB
        3. my-app-1.0-SNAPSHOT.jar
          2 kB

          Activity

            People

            • Assignee:
              CaptainEXA Captain EXASOL
              Reporter:
              CaptainEXA Captain EXASOL
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: