Menu

#1726 Support FUNCTION RETURNS ... ARRAY for Java functions

current-release
open-fixed
functions (2)
5
2024-12-04
2024-12-02
No

Seems HSQLDB doesn't support custom Java functions returning arrays.

I implemented a couple of JSON supporting functions to bridge the two functionalities (JSON and ARRAY), only to find that the "signature was not found" if the return type is String[] and the FUNCTION RETURNS LONGVARCHAR ARRAY.
(I have also tried with VARCHAR, with a custom defined type etc).

Example of use case: Extract elements from an JSON array of subtrees, and work with that further using array SQL functions.

Until this is implemented, it would also be nice if attempts to create a function which returns ARRAY would fail with a hint that it is not suported, rather than saying the signature is not found.

    // Kotlin code, but an equivalent of Java's String[] - checked in javap
        @JvmStatic fun simpleArray(): Array<String> = arrayOf("a", "b", "c")


  // SQL (works when return type is just VARCHAR)
     CREATE FUNCTION simpleArray()
                        RETURNS VARCHAR ARRAY
                        LANGUAGE JAVA PARAMETER STYLE JAVA
                        EXTERNAL NAME 'CLASSPATH:${javaClass.name}.simpleArray'

Thanks for considering.

Discussion

  • Fred Toussi

    Fred Toussi - 2024-12-04
    • status: open --> open-fixed
    • assigned_to: Fred Toussi
     
  • Fred Toussi

    Fred Toussi - 2024-12-04

    Thanks for reporting. Fixed and committed to SVN.
    A usage example is in SVN /base/trunk/src/org/hsqldb/test/TestRoutines.java
    Please build the jar and test and report the result.

     

Log in to post a comment.

MongoDB Logo MongoDB