Skip to content

Commit

Permalink
Verify n gql (#855)
Browse files Browse the repository at this point in the history
* verify nGQL

* merge new console table format

Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com>
  • Loading branch information
cooper-lzy and yixinglu committed Nov 1, 2021
1 parent b322450 commit 1fdccab
Show file tree
Hide file tree
Showing 80 changed files with 495 additions and 933 deletions.
51 changes: 20 additions & 31 deletions docs-2.0/2.quick-start/4.nebula-graph-crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ A Nebula Graph instance consists of one or more graph spaces. Graph spaces are p

To insert data into a graph space, define a schema for the graph database. Nebula Graph schema is based on the following components.

| Schema component | Description |
| ---------------- | --------------------------------------------------------------------------------------- |
| Vertex | Represents an entity in the real world. A vertex can have one or more tags. |
| Schema component | Description |
| ---------------- | --------------------------------------------------------------------------------------- |
| Vertex | Represents an entity in the real world. A vertex can have one or more tags. |
| Tag | The type of the same group of vertices. It defines a set of properties that describes the types of vertices. |
| Edge | Represents a **directed** relationship between two vertices. |
| Edge type | The type of an edge. It defines a group of properties that describes the types of edges. |
| Edge | Represents a **directed** relationship between two vertices. |
| Edge type | The type of an edge. It defines a group of properties that describes the types of edges. |

For more information, see [Data modeling](../1.introduction/2.data-model.md).

Expand All @@ -37,11 +37,8 @@ nebula> SHOW HOSTS;
| Host | Port | Status | Leader count | Leader distribution | Partition distribution |
+-------------+-----------+-----------+--------------+----------------------+------------------------+
| "storaged0" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-------------+-----------+-----------+--------------+----------------------+------------------------+
| "storaged1" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-------------+-----------+-----------+--------------+----------------------+------------------------+
| "storaged2" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-------------+-----------+-----------+--------------+----------------------+------------------------+
| "Total" | __EMPTY__ | __EMPTY__ | 0 | __EMPTY__ | __EMPTY__ |
+-------------+-----------+-----------+--------------+----------------------+------------------------+
Got 4 rows (time spent 1061/2251 us)
Expand Down Expand Up @@ -81,7 +78,7 @@ To make sure the follow-up operations work as expected, take one of the followin

```ngql
CREATE SPACE [IF NOT EXISTS] <graph_space_name> (
[partition_num = <partition_number>,]
[partition_num = <partition_number>,]
[replica_factor = <replica_number>,]
vid_type = {FIXED_STRING(<N>) | INT64}
)
Expand Down Expand Up @@ -124,11 +121,8 @@ To make sure the follow-up operations work as expected, take one of the followin
| Host | Port | Status | Leader count | Leader distribution | Partition distribution |
+-------------+-----------+-----------+--------------+----------------------------------+------------------------+
| "storaged0" | 9779 | "ONLINE" | 5 | "basketballplayer:5" | "basketballplayer:5" |
+-------------+-----------+-----------+--------------+----------------------------------+------------------------+
| "storaged1" | 9779 | "ONLINE" | 5 | "basketballplayer:5" | "basketballplayer:5" |
+-------------+-----------+-----------+--------------+----------------------------------+------------------------+
| "storaged2" | 9779 | "ONLINE" | 5 | "basketballplayer:5" | "basketballplayer:5" |
+-------------+-----------+-----------+--------------+----------------------------------+------------------------+
| "Total" | | | 15 | "basketballplayer:15" | "basketballplayer:15" |
+-------------+-----------+-----------+--------------+----------------------------------+------------------------+
Got 4 rows (time spent 1633/2867 us)
Expand Down Expand Up @@ -171,8 +165,8 @@ For more information on parameters, see [CREATE TAG](../3.ngql-guide/10.tag-stat

Create tags `player` and `team`, edge types `follow` and `serve`. Descriptions are as follows.

| Component name | Type | Property |
| :--- | :--- | :--- |
| Component name | Type | Property |
| :--- | :--- | :--- |
| player | Tag | name (string), age (int) |
| team | Tag | name (string) |
| follow | Edge type | degree (int) |
Expand Down Expand Up @@ -283,9 +277,9 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi
* Fetch properties on tags:

```ngql
FETCH PROP ON {<tag_name>[, tag_name ...] | *}
<vid> [, vid ...]
[YIELD <return_list> [AS <alias>]];
FETCH PROP ON {<tag_name>[, tag_name ...] | *}
<vid> [, vid ...]
[YIELD <return_list> [AS <alias>]];
```

* Fetch properties on edges:
Expand All @@ -298,8 +292,8 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi
* `LOOKUP`

```ngql
LOOKUP ON {<vertex_tag> | <edge_type>}
[WHERE <expression> [AND <expression> ...]]
LOOKUP ON {<vertex_tag> | <edge_type>}
[WHERE <expression> [AND <expression> ...]]
[YIELD <return_list> [AS <alias>]];
```

Expand Down Expand Up @@ -334,16 +328,15 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi
| Teammate | Age |
+-----------------+-----+
| "Tony Parker" | 36 |
+-----------------+-----+
| "Manu Ginobili" | 41 |
+-----------------+-----+
```

|Clause/Sign|Description|
|-|-|
|`YIELD`|Specifies what values or results you want to return from the query.|
|`$$`|Represents the target vertices.|
|`\`|A line-breaker.|
| Clause/Sign | Description |
|-------------+---------------------------------------------------------------------|
| `YIELD` | Specifies what values or results you want to return from the query. |
| `$$` | Represents the target vertices. |
| `\` | A line-breaker. |

* Search for the players that the player with VID `player100` follows. Then Retrieve the teams of the players that the player with VID `player100` follows. To combine the two queries, use a pipe or a temporary variable.

Expand All @@ -357,11 +350,9 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi
| Team | Player |
+-----------+-----------------+
| "Spurs" | "Tony Parker" |
+-----------+-----------------+
| "Hornets" | "Tony Parker" |
+-----------+-----------------+
| "Spurs" | "Manu Ginobili" |
+-----------+-----------------+
+-----------+-----------------+
```

|Clause/Sign|Description|
Expand All @@ -384,9 +375,7 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi
| Team | Player |
+-----------+-----------------+
| "Spurs" | "Tony Parker" |
+-----------+-----------------+
| "Hornets" | "Tony Parker" |
+-----------+-----------------+
| "Spurs" | "Manu Ginobili" |
+-----------+-----------------+
```
Expand Down Expand Up @@ -540,7 +529,7 @@ Users can add indexes to tags and edge types with the [CREATE INDEX](../3.ngql-g
* Create an index:

```ngql
CREATE {TAG | EDGE} INDEX [IF NOT EXISTS] <index_name>
CREATE {TAG | EDGE} INDEX [IF NOT EXISTS] <index_name>
ON {<tag_name> | <edge_name>} ([<prop_name_list>]) [COMMENT = '<comment>'];
```

Expand Down
14 changes: 7 additions & 7 deletions docs-2.0/20.appendix/0.FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Nebula Graph is still under development. Its behavior changes from time to time.

!!! compatibility "`X` version compatibility"

Neubla Graph {{ nebula.release }} is **not compatible** with Nebula Graph 1.x nor 2.0-RC in both data formats and RPC-protocols, and **vice versa**.
Neubla Graph {{ nebula.release }} is **not compatible** with Nebula Graph 1.x nor 2.0-RC in both data formats and RPC-protocols, and **vice versa**.
To upgrade data formats, see [Upgrade Nebula Graph to v2.0.0](../4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-260.md).
Users must upgrade [all clients](../20.appendix/6.eco-tool-version.md).

Expand Down Expand Up @@ -146,7 +146,7 @@ See [show-stats](../3.ngql-guide/7.general-query-statements/6.show/14.show-stats
> CREATE TAG INDEX i_player ON player();
> REBUILD TAG INDEX i_player;
```

2. Use `LOOKUP` or `MATCH`. For example:

```ngql
Expand Down Expand Up @@ -325,11 +325,11 @@ Hosts with the status of `OFFLINE` will be automatically deleted after one day.

If you have not modified the predefined ports in the [Configurations](../5.configurations-and-logs/1.configurations/1.configurations.md), open the following ports for the Nebula Graph services:

|Service|Port|
|-|-|
|Meta|9559, 9560, 19559, 19560|
|Graph|9669, 19669, 19670|
|Storage|9777 ~ 9780, 19779, 19780|
| Service | Port |
|---------+---------------------------|
| Meta | 9559, 9560, 19559, 19560 |
| Graph | 9669, 19669, 19670 |
| Storage | 9777 ~ 9780, 19779, 19780 |

If you have customized the configuration files and changed the predefined ports, find the port numbers in your configuration files and open them on the firewalls.

Expand Down
1 change: 0 additions & 1 deletion docs-2.0/3.ngql-guide/10.tag-statements/4.show-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ nebula> SHOW TAGS;
| Name |
+----------+
| "player" |
+----------+
| "team" |
+----------+
```
1 change: 0 additions & 1 deletion docs-2.0/3.ngql-guide/10.tag-statements/5.describe-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ nebula> DESCRIBE TAG player;
| Field | Type | Null | Default | Comment |
+--------+----------+-------+---------+---------+
| "name" | "string" | "YES" | | |
+--------+----------+-------+---------+---------+
| "age" | "int64" | "YES" | | |
+--------+----------+-------+---------+---------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ nebula> SHOW EDGES;
| Name |
+----------+
| "follow" |
+----------+
| "serve" |
+----------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ nebula> INSERT VERTEX t5(p1, p2, p3) VALUES "001":("Abe", 2, 3);
# In the following example, the insertion fails because the value of p1 cannot be NULL.
nebula> INSERT VERTEX t5(p1, p2, p3) VALUES "002":(NULL, 4, 5);
[ERROR (-8)]: Storage Error: The not null field cannot be null.
[ERROR (-1005)]: Storage Error: The not null field cannot be null.
# In the following example, the value of p3 is the default NULL.
nebula> INSERT VERTEX t5(p1, p2) VALUES "003":("cd", 5);
Expand Down
35 changes: 21 additions & 14 deletions docs-2.0/3.ngql-guide/12.vertex-statements/3.upsert-vertex.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ SET <update_prop>
[YIELD <output>]
```

| Parameter | Required | Description | Example |
|-|-|-|-|
| `ON <tag>` | Yes | Specifies the tag of the vertex. The properties to be updated must be on this tag. | `ON player` |
| `<vid>` | Yes | Specifies the ID of the vertex to be updated or inserted. | `"player100"` |
| `SET <update_prop>` | Yes | Specifies the properties to be updated and how they will be updated. | `SET age = age +1` |
| `WHEN <condition>` | No | Specifies the filter conditions. | `WHEN name == "Tim"` |
| `YIELD <output>` | No | Specifies the output format of the statement. | `YIELD name AS Name` |
| Parameter | Required | Description | Example |
|---------------------+----------+------------------------------------------------------------------------------------+----------------------|
| `ON <tag>` | Yes | Specifies the tag of the vertex. The properties to be updated must be on this tag. | `ON player` |
| `<vid>` | Yes | Specifies the ID of the vertex to be updated or inserted. | `"player100"` |
| `SET <update_prop>` | Yes | Specifies the properties to be updated and how they will be updated. | `SET age = age +1` |
| `WHEN <condition>` | No | Specifies the filter conditions. | `WHEN name == "Tim"` |
| `YIELD <output>` | No | Specifies the output format of the statement. | `YIELD name AS Name` |

## Insert a vertex if it does not exist

Expand All @@ -45,18 +45,22 @@ For example, if:

Then the property values in different cases are listed as follows:

| Are `WHEN` conditions met | If properties have default values | Value of `name` | Value of `age` |
| - | - | - | - |
| Yes | Yes | The default value | `30` |
| Yes | No | `NULL` | `30` |
| No | Yes | The default value | `30` |
| No | No | `NULL` | `30` |
| Are `WHEN` conditions met | If properties have default values | Value of `name` | Value of `age` |
|---------------------------+-----------------------------------+-------------------+----------------|
| Yes | Yes | The default value | `30` |
| Yes | No | `NULL` | `30` |
| No | Yes | The default value | `30` |
| No | No | `NULL` | `30` |

Here are some examples:

```ngql
// This query checks if the following three vertices exist. The result "Empty set" indicates that the vertices do not exist.
nebula> FETCH PROP ON * "player666", "player667", "player668";
+-----------+
| vertices_ |
+-----------+
+-----------+
Empty set
nebula> UPSERT VERTEX ON player "player666" \
Expand All @@ -69,7 +73,10 @@ nebula> UPSERT VERTEX ON player "player666" \
| __NULL__ | 30 |
+----------+----------+
nebula> UPSERT VERTEX ON player "player666" SET age = 31 WHEN name == "Joe" YIELD name AS Name, age AS Age;
nebula> UPSERT VERTEX ON player "player666" \
SET age = 31 \
WHEN name == "Joe" \
YIELD name AS Name, age AS Age;
+----------+-----+
| Name | Age |
+----------+-----+
Expand Down
18 changes: 9 additions & 9 deletions docs-2.0/3.ngql-guide/13.edge-statements/2.update-edge.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ SET <update_prop>
[YIELD <output>]
```

| Parameter | Required | Description | Example |
|-|-|-|-|
| `ON <edge_type>` | Yes | Specifies the edge type. The properties to be updated must be on this edge type. | `ON serve` |
| `<src_vid>` | Yes | Specifies the source vertex ID of the edge. | `"player100"` |
| `<dst_vid>` | Yes | Specifies the destination vertex ID of the edge. | `"team204"` |
| `<rank>` | No | Specifies the rank of the edge. | `10` |
| `SET <update_prop>` | Yes | Specifies the properties to be updated and how they will be updated. | `SET start_year = start_year +1` |
| `WHEN <condition>` | No | Specifies the filter conditions. If `<condition>` evaluates to `false`, the `SET` clause does not take effect. | `WHEN end_year < 2010` |
| `YIELD <output>` | No | Specifies the output format of the statement. | `YIELD start_year AS Start_Year` |
| Parameter | Required | Description | Example |
|---------------------+----------+----------------------------------------------------------------------------------------------------------------+----------------------------------|
| `ON <edge_type>` | Yes | Specifies the edge type. The properties to be updated must be on this edge type. | `ON serve` |
| `<src_vid>` | Yes | Specifies the source vertex ID of the edge. | `"player100"` |
| `<dst_vid>` | Yes | Specifies the destination vertex ID of the edge. | `"team204"` |
| `<rank>` | No | Specifies the rank of the edge. | `10` |
| `SET <update_prop>` | Yes | Specifies the properties to be updated and how they will be updated. | `SET start_year = start_year +1` |
| `WHEN <condition>` | No | Specifies the filter conditions. If `<condition>` evaluates to `false`, the `SET` clause does not take effect. | `WHEN end_year < 2010` |
| `YIELD <output>` | No | Specifies the output format of the statement. | `YIELD start_year AS Start_Year` |

## Example

Expand Down
28 changes: 14 additions & 14 deletions docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ SET <update_prop>
[YIELD <properties>]
```

| Parameter | Required | Description | Example |
|-|-|-|-|
| `ON <edge_type>` | Yes | Specifies the edge type. The properties to be updated must be on this edge type. | `ON serve` |
| `<src_vid>` | Yes | Specifies the source vertex ID of the edge. | `"player100"` |
| `<dst_vid>` | Yes | Specifies the destination vertex ID of the edge. | `"team204"` |
| `<rank>` | No | Specifies the rank of the edge. | `10` |
| `SET <update_prop>` | Yes | Specifies the properties to be updated and how they will be updated. | `SET start_year = start_year +1` |
| `WHEN <condition>` | No | Specifies the filter conditions. | `WHEN end_year < 2010` |
| `YIELD <output>` | No | Specifies the output format of the statement. | `YIELD start_year AS Start_Year` |
| Parameter | Required | Description | Example |
|---------------------+----------+----------------------------------------------------------------------------------+----------------------------------|
| `ON <edge_type>` | Yes | Specifies the edge type. The properties to be updated must be on this edge type. | `ON serve` |
| `<src_vid>` | Yes | Specifies the source vertex ID of the edge. | `"player100"` |
| `<dst_vid>` | Yes | Specifies the destination vertex ID of the edge. | `"team204"` |
| `<rank>` | No | Specifies the rank of the edge. | `10` |
| `SET <update_prop>` | Yes | Specifies the properties to be updated and how they will be updated. | `SET start_year = start_year +1` |
| `WHEN <condition>` | No | Specifies the filter conditions. | `WHEN end_year < 2010` |
| `YIELD <output>` | No | Specifies the output format of the statement. | `YIELD start_year AS Start_Year` |

## Insert an edge if it does not exist

Expand All @@ -45,11 +45,11 @@ For example, if:
Then the property values in different cases are listed as follows:

| Are `WHEN` conditions met | If properties have default values | Value of `start_year` | Value of `end_year` |
| - | - | - | - |
| Yes | Yes | The default value | `2021` |
| Yes | No | `NULL` | `2021` |
| No | Yes | The default value | `2021` |
| No | No | `NULL` | `2021` |
| - | - | - | - |
| Yes | Yes | The default value | `2021` |
| Yes | No | `NULL` | `2021` |
| No | Yes | The default value | `2021` |
| No | No | `NULL` | `2021` |

Here are some examples:

Expand Down
Loading

0 comments on commit 1fdccab

Please sign in to comment.