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 EMPTY #624

Merged
merged 3 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 9 additions & 7 deletions docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## 语法

```ngql
FIND { SHORTEST | ALL | NOLOOP } PATH FROM <vertex_id_list> TO <vertex_id_list>
FIND { SHORTEST | ALL | NOLOOP } PATH [WITH PROP] FROM <vertex_id_list> TO <vertex_id_list>
OVER <edge_type_list> [REVERSELY | BIDIRECT] [<WHERE clause>] [UPTO <N> STEPS] [| ORDER BY $-.path] [| LIMIT <M>];

<vertex_id_list> ::=
Expand All @@ -18,6 +18,8 @@ OVER <edge_type_list> [REVERSELY | BIDIRECT] [<WHERE clause>] [UPTO <N> STEPS] [

- `NOLOOP`:查找非循环路径。

- `WITH PROP`:展示点和边的属性。不添加本参数则隐藏属性。

- `<vertex_id_list>`:点ID列表.多个点用英文逗号(,)分隔。支持`$-`和`$var`。

- `<edge_type_list>`:边类型列表.多个边类型用英文逗号(,)分隔。`*`表示所有边类型。
Expand Down Expand Up @@ -58,12 +60,12 @@ nebula> FIND SHORTEST PATH FROM "player102" TO "team204" OVER *;
```

```ngql
nebula> FIND SHORTEST PATH FROM "team204" TO "player100" OVER * REVERSELY;
+--------------------------------------------+
| path |
+--------------------------------------------+
| <("team204")<-[:serve@0 {}]-("player100")> |
+--------------------------------------------+
nebula> FIND SHORTEST PATH WITH PROP FROM "team204" TO "player100" OVER * REVERSELY;
+--------------------------------------------------------------------------------------------------------------------------------------+
| path |
+--------------------------------------------------------------------------------------------------------------------------------------+
| <("team204" :team{name: "Spurs"})<-[:serve@0 {end_year: 2016, start_year: 1997}]-("player100" :player{age: 42, name: "Tim Duncan"})> |
+--------------------------------------------------------------------------------------------------------------------------------------+
```

```ngql
Expand Down
38 changes: 36 additions & 2 deletions docs-2.0/3.ngql-guide/5.operators/1.comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ Nebula Graph支持的比较符如下。
| `-` | 负数符号 |
| `IS NULL` | 为NULL|
| `IS NOT NULL` | 不为NULL |
| `IS EMPTY` | 不存在|
| `IS NOT EMPTY` | 存在 |

比较操作的结果是`true`或者`false`。

!!! Note

比较不同类型的值通常没有定义,结果可能是NULL或其它。
- 比较不同类型的值通常没有定义,结果可能是`NULL`或其它。

- `EMPTY`当前仅用于判断,不支持函数或者运算操作,包括且不限于`GROUP BY`、`count()`、`sum()`、`max()`、`hash()`、`collect()`、`+`、`*`。

## OpenCypher兼容性

Nebula Graph中,NULL的比较操作和openCypher不同,行为也可能会改变。在openCypher中,`IS [NOT] NULL`通常与`OPTIONAL MATCH`一起使用,但是nGQL不支持`OPTIONAL MATCH`。
- `NULL`的比较操作和openCypher不同,行为也可能会改变。在openCypher中,`IS [NOT] NULL`通常与`OPTIONAL MATCH`一起使用,但是nGQL不支持`OPTIONAL MATCH`。

- openCypher中没有`EMPTY`,因此不支持在MATCH语句中使用`EMPTY`。

## 示例

Expand Down Expand Up @@ -164,3 +170,31 @@ nebula> MATCH (n:player) \
+---------------+--------------------+-----------------+
...
```

### `IS [NOT] EMPTY`

```ngql
nebula> RETURN null IS EMPTY;
+---------------+
| NULL IS EMPTY |
+---------------+
| false |
+---------------+

nebula> RETURN "a" IS NOT EMPTY;
+------------------+
| "a" IS NOT EMPTY |
+------------------+
| true |
+------------------+

nebula> GO FROM "player100" OVER * WHERE $$.player.name IS NOT EMPTY YIELD follow._dst;
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved
+-------------+
| follow._dst |
+-------------+
| "player125" |
+-------------+
| "player101" |
+-------------+

```