Miscellaneous Functions
This page lists the functions in the GSQL query language that are not tied to any single data type.
coalesce()
coalesce()
Syntax
coalesce( exp [, exp ...] )
Description
Returns the first expression that isn't NULL
.
This function requires all its arguments have the same data type (BOOL
, INT
, FLOAT,
DOUBLE
, STRING
, or VERTEX
). The only exception is that different numeric types can be used together. In this case, all values are converted into the first argument type.
Return type
BOOL
, INT
, FLOAT,
DOUBLE
, STRING
, or VERTEX
Parameters
The function takes a number of parameters and returns the first one that does not evaluate to NULL
Example
evaluate()
evaluate()
Syntax
evaluate( expressionStr, typeStr )
Description
Takes a string argument and interprets it as an expression which is evaluated during run-time. This enables users to create a general purpose query instead of separate queries for each specific computation.
This function cannot be nested.
The following situations generate a run-time error:
The expression string expressionStr cannot be compiled (unless the error is due to a non-existent vertex or edge attribute).
The result type of the expression does not match the parameter typeStr.
Silent failure conditions
If any of the following conditions occur, the query may continue running, but the entire clause or statement in which the evaluate() function resides will fail, without producing a run-time error message. For conditional clauses (WHERE, HAVING), a failing evaluate() clause is treated as if the condition is false. An assignment statement with a failing evaluate() will not execute, and an ORDER BY clause with a failing evaluate() will not sort.
The expression references a non-existent attribute of a vertex or edge alias.
The expression uses an operator for non-compatible operation. For example, 123 == "xyz".
Return type
Tyep indicated by typeStr
Parameters
Parameter | Description | Data type |
| The expression to evaluate typed as a string.
|
|
| The return type for the function call. It must be a string literal for a primitive data type, e.g., one of |
|
Example
Last updated