Skip to content

Commit

Permalink
add toSet function (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-lzy authored Apr 20, 2022
1 parent b5d3b93 commit 13eb59e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions docs-2.0/3.ngql-guide/3.data-types/9.type-conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

Converting an expression of a given type to another type is known as type conversion.

## Legacy version compatibility

* nGQL 1.0 adopts the `C`-style of type conversion (implicitly or explicitly): `(type_name)expression`. For example, the results of `YIELD (int)(TRUE)` is `1`. But it is error-prone to users who are not familiar with the C language.

* since nGQL 2.0, the openCypher way of type coercions is adopted.

## Type coercions functions

| Function | Description |
| - | - |
| toBoolean() | Converts a string value to a boolean value. |
| toFloat() | Converts an integer or string value to a floating point number. |
| toInteger() | Converts a floating point or string value to an integer value. |
| toSet() | Converts a list or set value to a set value.|
| type() | Returns the string representation of the relationship type. |

## Examples
Expand Down Expand Up @@ -72,4 +67,17 @@ nebula> MATCH (n:player) \
+-------+
| 2 |
+-------+
nebula> RETURN toSet(list[1,2,3,1,2]) AS list2set;
+-----------+
| list2set |
+-----------+
| {3, 1, 2} |
+-----------+
nebula> RETURN toSet(set{1,2,3,1,2}) AS set2set;
+-----------+
| set2set |
+-----------+
| {3, 2, 1} |
+-----------+
```

0 comments on commit 13eb59e

Please sign in to comment.