From 8ceb7adc9901392494e16d64bf8c86346c92b585 Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:47:21 +0800 Subject: [PATCH] Add distinct --- .../7.general-query-statements/4.fetch.md | 2 +- .../7.general-query-statements/5.lookup.md | 4 +++- .../3.ngql-guide/8.clauses-and-options/yield.md | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md b/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md index 792085aed47..9715e49c035 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md @@ -15,7 +15,7 @@ This topic applies to native nGQL only. ```ngql FETCH PROP ON {[, tag_name ...] | *} [, vid ...] -YIELD [AS ]; +YIELD [DISTINCT] [AS ]; ``` | Parameter | Description | diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md b/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md index c601d942f93..340bfc59d93 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md @@ -37,7 +37,7 @@ Before using the `LOOKUP` statement, make sure that at least one index is create ```ngql LOOKUP ON { | } [WHERE [AND ...]] -YIELD [AS ]; +YIELD [DISTINCT] [AS ]; [AS ] [, [AS ] ...]; @@ -47,6 +47,8 @@ YIELD [AS ]; - `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` diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md index 4fc96f3d5e4..e463c0ee6a0 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md @@ -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.