User-Defined Functions

Overview

CrateDB supports user-defined functions (UDFs) that can be written in JavaScript.

Reference Manual

SQL Functions

SQL UDF

Synopsis

Define function.

CREATE FUNCTION my_subtract_function(integer, integer)
RETURNS integer
LANGUAGE JAVASCRIPT
AS 'function my_subtract_function(a, b) { return a - b; }';

Use function.

SELECT doc.my_subtract_function(3, 1) AS col;
+-----+
| col |
+-----+
|   2 |
+-----+
SELECT 1 row in set (... sec)

Note

This page is currently under construction. It includes not even the most basic essentials, and needs expansion. For example, the “About”, “Details”, “Usage” and “Learn” sections are missing completely.

See also

Product: Relational Database