Syntax

Simply wrap your JavaScript functions within the script {{{ <your JavaScript code> }}} tag and then continue constructing your SQL query as usual. The JavaScript functions that you’d like to use in SQL must be exported as if your script was a JavaScript module.

script {{{
<your JavaScript code>
}}}

SELECT ...

Hello World Example

script {{{
export function helloworld(name) {
    return 'hello, ' + name
}
}}}

SELECT _script.helloworld('ferro');

The above code will return:

hello, ferro

Note that, while JavaScript can use both single and double quotes for strings (’hello’ and "hello" would both work), Rockset SQL only allows single quotes (’ferro’, NOT "ferro").