Ultipa GQLDB supports stored procedures for encapsulating complex graph logic, enabling reusable queries, and implementing high-performance graph algorithms.
GQLCREATE PROCEDURE greet(name: STRING) RETURNS (message: STRING) AS { RETURN 'Hello ' || $name AS message }
GQLCALL greet('World') YIELD message -- Returns: "Hello World"
GQLDROP PROCEDURE greet
Stored procedures in Ultipa GQLDB are an extension to the GQL standard (ISO/IEC 39075). The GQL standard does not yet define syntax for creating or dropping stored procedures - CREATE PROCEDURE, DROP PROCEDURE, SHOW PROCEDURES, and the procedure body language are all Ultipa-specific extensions.
The procedure body (AS { ... }) is written in a procedural language that builds on GQL syntax. It supports GQL statements like MATCH, INSERT, SET, DELETE, RETURN, and all standard GQL functions. On top of that, it adds:
IF / ELSE IF / ELSE, FOR, WHILE, BREAK, CONTINUETRY / CATCH / THROWPARALLEL FOR with WORKERSLET for declaration and assignmentPRINT for output to stderrStored procedures work without the compute engine. Control flow (IF, FOR, WHILE, TRY/CATCH), data operations (LET, MATCH, INSERT, SET, DELETE), standard GQL functions, set/map operations, and type conversions are all available by default.
For graph algorithm workloads, enable the compute engine per graph:
GQLALTER GRAPH <graph_name> SET COMPUTE ENABLED
This is required for:
OUT_DEGREE, IN_DEGREE, NODE_COUNTSUM_OUT_NEIGHBOR_PROP, IN_NEIGHBOR_SUM, MIN_BOTH_NEIGHBOR_PROP, etc.INIT_SLICE_PROP, GET_SLICE_PROP, SET_SLICE_PROP, PARALLEL FOR with SCAN()SUM_SLICE_PROP, MAX_SLICE_PROP, etc.COMMON_NEIGHBORS, JACCARD_SIMILARITY, ADAMIC_ADARBATCH_MAP_TO_SLICE, BATCH_PERSIST_SLICE, etc.Without the compute engine, these functions return 0 or default values.