Converts a value to the specified type.
| Syntax | cast(<value> AS <type>) | ||
| Arguments | Name | Type | Description |
<value> | Any | The value to convert | |
<type> | / | Target type (see supported types below) | |
| Return Type | As specified by <type> | ||
Supported target types:
| Category | Types |
|---|---|
| Integer | INT, INTEGER, INT8, INT16, INT32, INT64, UINT, UINT8, UINT16, UINT32, UINT64 |
| Float | FLOAT, FLOAT32, FLOAT64, DOUBLE, DECIMAL, REAL |
| String | STRING, TEXT, VARCHAR |
| Boolean | BOOL, BOOLEAN |
| Temporal | DATE, LOCAL TIME, LOCAL DATETIME, TIMESTAMP, ZONED DATETIME, DURATION |
| Collection | LIST, RECORD |
| Binary | BYTES, BINARY |
GQLRETURN cast(1 AS STRING), cast("42" AS INT), cast("true" AS BOOL)
Converts a value to an integer. Returns null if conversion is not possible.
| Syntax | toInteger(<value>) | ||
| Arguments | Name | Type | Description |
<value> | INT, FLOAT, BOOL, or STRING | The value to convert | |
| Return Type | INT | ||
GQLRETURN toInteger("42"), toInteger(3.7), toInteger(true)
Result: 42, 3, 1
Converts a value to a float. Returns null if conversion is not possible.
| Syntax | toFloat(<value>) | ||
| Arguments | Name | Type | Description |
<value> | FLOAT, INT, BOOL, or STRING | The value to convert | |
| Return Type | FLOAT | ||
GQLRETURN toFloat("3.14"), toFloat(42), toFloat(true)
Result: 3.14, 42, 1
Converts a value to a string. Returns null if conversion is not possible.
| Syntax | toString(<value>) | ||
| Arguments | Name | Type | Description |
<value> | Any | The value to convert | |
| Return Type | STRING | ||
GQLRETURN toString(42), toString(3.14), toString(true)
Result: "42", "3.14", "true"
Converts a value to a boolean. Returns null if conversion is not possible. Accepted string values: "true", "t", "yes", "y", "1" for true; "false", "f", "no", "n", "0" for false (case-insensitive).
| Syntax | toBoolean(<value>) | ||
| Arguments | Name | Type | Description |
<value> | BOOL, INT, FLOAT, or STRING | The value to convert | |
| Return Type | BOOL | ||
GQLRETURN toBoolean("true"), toBoolean(1), toBoolean("yes")
Result: true, true, true
Converts a value to a list. Strings are split into a list of characters. Paths are converted to a list of alternating nodes and edges. Other values are wrapped in a single-element list.
| Syntax | toList(<value>) | ||
| Arguments | Name | Type | Description |
<value> | Any | The value to convert | |
| Return Type | LIST | ||
GQLRETURN toList("hello")
Result: ["h", "e", "l", "l", "o"]
Creates a record (map) from key-value pairs.
| Syntax | toMap(<key1>, <value1> [, <key2>, <value2>, ...]) | ||
| Arguments | Name | Type | Description |
<key> | STRING | A key name | |
<value> | Any | The value for the preceding key | |
| Return Type | RECORD | ||
GQLRETURN toMap("name", "Alice", "age", 30)
Result: {"name": "Alice", "age": 30}