dynamobi/dynamobi — Issue #544: [FRG-328] Executing UDF in package-unqualified class raises org.codehaus.janino.CompileException
Author: dynamobi-build
Created: 2011-12-30 03:34:34+00:00
State: open
Labels: FRG, UDF

[reporter="emcdermid", created="Fri, 8 Aug 2008 08:35:19 -0500 (GMT-05:00)"]
Farrago seems to have issues with UDFs implemented in Java classes located in an external JAR file (as opposed to those in the farrago jar file itself).

Reproduction case:

Create a new schema to handle extensions and set the schema and path to point to it:

CREATE SCHEMA geocache;

SET SCHEMA 'geocache';

SET PATH 'geocache';

Create a Degree.java file containing the following code:

class Degree {

public static double getFraction( double degrees ) {

return( degrees - (int)degrees );

}

public static int getMinutes( double degrees ) {

return( (int)(getFraction(degrees) * 60.0) );

}

public static int getSeconds( double degrees ) {

return( (int)(((getFraction(degrees) * 3600.0) - ((getMinutes(degrees) * 60)) ) );

}

}

Package the Java class up into a JAR file so that SQLstream Server can load it:

jar cf gps.jar Degree.class

Once the gps.jar file is created, we move it to the machine SQLstream Server is running on and CALL the system-defined SQLJ.INSTALL_JAR routine to install the jar file. (In the example below, we assume it is located in /home/aspen/gps.jar).

CALL SQLJ.INSTALL_JAR('file:/home/aspen/gps.jar', 'GPSFuncsJavaLib', 0);

Use CREATE FUNCTION to make the getFraction routine available from SQL:

CREATE FUNCTION get_fraction( degrees DOUBLE )

RETURNS DOUBLE

NO SQL

LANGUAGE JAVA

PARAMETER STYLE JAVA

EXTERNAL NAME 'GPSFuncsJavaLib:Degree.getFraction'

;

Now, try invoking the function. For example:

values( get_fraction(1.33) );

Result:

Error: org.codehaus.janino.CompileException: File /home/eric/workspace/farrago/classes/net/sf/farrago/dynamic/stmt27/Transformer1.java, Line 73, Column 39: Unknown variable or type "Degree" (state=,code=0)