Skip to content

Commit

Permalink
Add distinct (#1928)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-lzy authored Feb 7, 2023
1 parent ca0ffd4 commit 15e7cc8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This topic applies to native nGQL only.
```ngql
FETCH PROP ON {<tag_name>[, tag_name ...] | *}
<vid> [, vid ...]
YIELD <return_list> [AS <alias>];
YIELD [DISTINCT] <return_list> [AS <alias>];
```

| Parameter | Description |
Expand Down
4 changes: 3 additions & 1 deletion docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Before using the `LOOKUP` statement, make sure that at least one index is create
```ngql
LOOKUP ON {<vertex_tag> | <edge_type>}
[WHERE <expression> [AND <expression> ...]]
YIELD <return_list> [AS <alias>];
YIELD [DISTINCT] <return_list> [AS <alias>];
<return_list>
<prop_name> [AS <col_alias>] [, <prop_name> [AS <prop_alias>] ...];
Expand All @@ -47,6 +47,8 @@ YIELD <return_list> [AS <alias>];

- `YIELD`: Define the output to be returned. For details, see [`YIELD`](../8.clauses-and-options/yield.md).

- `DISTINCT`: Aggregate the output results and return the de-duplicated result set.

- `AS`: Set an alias.

## Limitations of using `WHERE` in `LOOKUP`
Expand Down
13 changes: 13 additions & 0 deletions docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ nebula> $var1 = GO FROM "player101" OVER follow \
+-------------+
```

The following query finds the vertices in the player that are older than 30 and younger than 32, and returns the de-duplicate results.

```ngql
nebula> LOOKUP ON player \
WHERE player.age < 32 and player.age >30 \
YIELD DISTINCT properties(vertex).age as v;
+--------+
| v |
+--------+
| 31 |
+--------+
```

### Use a standalone YIELD statement

A `YIELD` statement can calculate a valid expression and output the result.
Expand Down

0 comments on commit 15e7cc8

Please sign in to comment.