Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add toSet function #1649

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 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 @@

类型转换是指将表达式的类型转换为另一个类型。

## 遗留兼容问题

nGQL 1.0 使用 C 语言风格的类型转换(显示或隐式):`(type_name)expression`。例如`YIELD (int)(TRUE)`,结果为`1`。但是对于不熟悉 C 语言的用户来说,很容易出错。

从 nGQL 2.0 开始使用 openCypher 的方式进行类型强制转换。

## 类型强制转换函数

| 函数 | 说明 |
| :--- | :--- |
| toBoolean() | 将字符串转换为布尔。 |
| toFloat() | 将整数或字符串转换为浮点数。 |
| toInteger() | 将浮点或字符串转换为整数。|
| toSet() |将列表或集合转换为集合。|
| type() | 返回字符串格式的关系类型。 |

## 示例
Expand Down Expand Up @@ -76,4 +71,18 @@ 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} |
+-----------+
```