Type conversion functions convert values between different data types.
Converts a value to an integer.
Syntax:
TOINTEGER(value) -> int
Example:
GQLRETURN TOINTEGER('42') AS str_to_int, TOINTEGER(3.7) AS float_to_int
Result:
| str_to_int | float_to_int |
|---|---|
| 42 | 3 |
Converts a value to a float.
Syntax:
TOFLOAT(value) -> float
Example:
GQLRETURN TOFLOAT('3.14') AS str_to_float, TOFLOAT(42) AS int_to_float
Result:
| str_to_float | int_to_float |
|---|---|
| 3.14 | 42.0 |
Converts a value to a string.
Syntax:
TOSTRING(value) -> string
Example:
GQLRETURN TOSTRING(42) AS int_to_str, TOSTRING(3.14) AS float_to_str, TOSTRING(true) AS bool_to_str
Result:
| int_to_str | float_to_str | bool_to_str |
|---|---|---|
| "42" | "3.14" | "true" |
Converts a value to a boolean.
Syntax:
TOBOOLEAN(value) -> boolean
Example:
GQLRETURN TOBOOLEAN('true') AS str_to_bool, TOBOOLEAN(1) AS int_to_bool
Result:
| str_to_bool | int_to_bool |
|---|---|
| true | true |
Converts a value to a list.
Syntax:
TOLIST(value) -> list
Example:
GQLRETURN TOLIST('hello') AS str_to_list
Result:
| str_to_list |
|---|
| ["h", "e", "l", "l", "o"] |