Skip to content
Permalink
Browse files

[use manual] add more manuals (#742)

* 1. add group_by
2. add property reference
3. mv nebula 127 ..> to nebula>

* address judy & amber's comments

* add fetch

* add order by
  • Loading branch information...
whitewum authored and dutor committed Aug 13, 2019
1 parent 414d582 commit d128868f5a75fe34d0ae947a901f3cc807aa73fb
Showing with 290 additions and 107 deletions.
  1. +29 −29 docs/get-started.md
  2. +7 −7 docs/manual_doc/Functions_and_Operators/Comparison_Functions_and_Operators.md
  3. +1 −1 docs/manual_doc/Functions_and_Operators/Functions_and_Operator_Reference.md
  4. +26 −0 docs/manual_doc/Functions_and_Operators/Group_By_Function.md
  5. +4 −4 docs/manual_doc/Functions_and_Operators/Logical_Operators.md
  6. +2 −2 docs/manual_doc/Functions_and_Operators/Operator_Precedence.md
  7. +22 −0 docs/manual_doc/Functions_and_Operators/Order_By_Function.md
  8. 0 ...ta_Definition_Statements/Create_TAG_or_EDGE_Syntax.md → Functions_and_Operators/Set_Operation.md}
  9. +2 −0 docs/manual_doc/Functions_and_Operators/Type_Conversion.md
  10. +9 −8 docs/manual_doc/Language_Structure/Comment_Syntax.md
  11. +6 −6 docs/manual_doc/Language_Structure/Identifier_Case_Sensitivity.md
  12. 0 docs/manual_doc/Language_Structure/Keywords_and_Reserved_Words.md
  13. +1 −1 docs/manual_doc/Language_Structure/Literal_Values/Boolean_Literals.md
  14. +1 −1 docs/manual_doc/Language_Structure/Literal_Values/NULL_Values.md
  15. +4 −4 docs/manual_doc/Language_Structure/Literal_Values/String_Literals.md
  16. +68 −0 docs/manual_doc/Language_Structure/Property_Reference.md
  17. +4 −4 docs/manual_doc/Language_Structure/User-Defined_Variables.md
  18. +4 −4 docs/manual_doc/Statement_Syntax/DATA_Manipulation_Statements/{GO_Syntax.md → Go_Syntax.md}
  19. +11 −10 docs/manual_doc/Statement_Syntax/DATA_Manipulation_Statements/INSERT_EDGE_Syntax.md
  20. +6 −4 docs/manual_doc/Statement_Syntax/DATA_Manipulation_Statements/PIPE_Syntax.md
  21. +5 −5 docs/manual_doc/Statement_Syntax/DATA_Manipulation_Statements/YIELD_Syntax.md
  22. +60 −0 docs/manual_doc/Statement_Syntax/DATA_Manipulation_Statements/fetch_Syntax.md
  23. +6 −6 ..._doc/Statement_Syntax/Data_Administration_Statements/Configuration_Statements/Variables_Syntax.md
  24. 0 ...tement_Syntax/Data_Definition_Statements/{ALTER_TAG_or_EDGE_Syntax.md → Alter_Tag_Edge_Syntax.md}
  25. 0 docs/manual_doc/Statement_Syntax/Data_Definition_Statements/Create_Tag_Edge_Syntax.md
  26. +6 −6 docs/manual_doc/Statement_Syntax/Utility_Statements/DESCRIBE_syntax.md
  27. +6 −5 docs/manual_doc/Statement_Syntax/Utility_Statements/USE_syntax.md
@@ -112,7 +112,7 @@ To connect to the graph server, run
Welcome to Nebula Graph (Version 0.1)
(user@127.0.0.1) [(none)]>
nebula>
```

If you have any questions or concerns about the deployment procedures, please do not hesitate to open an issue on [GitHub](https://github.com/vesoft-inc/nebula/issues).
@@ -291,15 +291,15 @@ There are three kinds of tags (_course_, _building_ and _student_) and two edge

To list all existing spaces:
```
(user@127.0.0.1) [(none)]> SHOW SPACES;
nebula> SHOW SPACES;
```

To create a new space named myspace_test2 :
```
(user@127.0.0.1) [(none)]> CREATE SPACE myspace_test2(partition_num=1, replica_factor=1);
nebula> CREATE SPACE myspace_test2(partition_num=1, replica_factor=1);
-- Use this space
(user@127.0.0.1) [(none)]> USE myspace_test2;
nebula> USE myspace_test2;
```
`replica_factor` specifies the number of replicas in the cluster.

@@ -309,32 +309,32 @@ To create a new space named myspace_test2 :

The `CREATE TAG` statement defines a tag, with a type name and an attribute list.
```
(user@127.0.0.1) [(none)]> CREATE TAG course(name string, credits int);
(user@127.0.0.1) [(none)]> CREATE TAG building(name string);
(user@127.0.0.1) [(none)]> CREATE TAG student(name string, age int, gender string);
nebula> CREATE TAG course(name string, credits int);
nebula> CREATE TAG building(name string);
nebula> CREATE TAG student(name string, age int, gender string);
```
The `CREATE EDGE` statement defines an edge type.
```
(user@127.0.0.1) [(none)]> CREATE EDGE like(likeness double);
(user@127.0.0.1) [(none)]> CREATE EDGE select(grade int);
nebula> CREATE EDGE like(likeness double);
nebula> CREATE EDGE select(grade int);
```

To list the tags and edge types that we just created:
```
-- Show tag list
(user@127.0.0.1) [(none)]> SHOW TAGS;
nebula> SHOW TAGS;
-- Show edge type list
(user@127.0.0.1) [(none)]> SHOW EDGES;
nebula> SHOW EDGES;
```

To show the attributes of a tag or an edge type:
```
-- Show attributes of a tag
(user@127.0.0.1) [(none)]> DESCRIBE TAG student;
nebula> DESCRIBE TAG student;
-- Show attributes of an edge type
(user@127.0.0.1) [(none)]> DESCRIBE EDGE like;
nebula> DESCRIBE EDGE like;
```


@@ -345,31 +345,31 @@ Insert the vertices and edges based on the graph above.
```
-- Insert vertices
(user@127.0.0.1) [(none)]> INSERT VERTEX student(name, age, gender) VALUES 200:("Monica", 16, "female");
(user@127.0.0.1) [(none)]> INSERT VERTEX student(name, age, gender) VALUES 201:("Mike", 18, "male");
(user@127.0.0.1) [(none)]> INSERT VERTEX student(name, age, gender) VALUES 202:("Jane", 17, "female");
(user@127.0.0.1) [(none)]> INSERT VERTEX course(name, credits),building(name) VALUES 101:("Math", 3, "No5");
(user@127.0.0.1) [(none)]> INSERT VERTEX course(name, credits),building(name) VALUES 102:("English", 6, "No11");
nebula> INSERT VERTEX student(name, age, gender) VALUES 200:("Monica", 16, "female");
nebula> INSERT VERTEX student(name, age, gender) VALUES 201:("Mike", 18, "male");
nebula> INSERT VERTEX student(name, age, gender) VALUES 202:("Jane", 17, "female");
nebula> INSERT VERTEX course(name, credits),building(name) VALUES 101:("Math", 3, "No5");
nebula> INSERT VERTEX course(name, credits),building(name) VALUES 102:("English", 6, "No11");
```

```
-- Insert edges
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 200 -> 101:(5);
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 200 -> 102:(3);
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 201 -> 102:(3);
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 202 -> 102:(3);
(user@127.0.0.1) [(none)]> INSERT EDGE like(likeness) VALUES 200 -> 201:(92.5);
(user@127.0.0.1) [(none)]> INSERT EDGE like(likeness) VALUES 201 -> 200:(85.6);
(user@127.0.0.1) [(none)]> INSERT EDGE like(likeness) VALUES 201 -> 202:(93.2);
nebula> INSERT EDGE select(grade) VALUES 200 -> 101:(5);
nebula> INSERT EDGE select(grade) VALUES 200 -> 102:(3);
nebula> INSERT EDGE select(grade) VALUES 201 -> 102:(3);
nebula> INSERT EDGE select(grade) VALUES 202 -> 102:(3);
nebula> INSERT EDGE like(likeness) VALUES 200 -> 201:(92.5);
nebula> INSERT EDGE like(likeness) VALUES 201 -> 200:(85.6);
nebula> INSERT EDGE like(likeness) VALUES 201 -> 202:(93.2);
```

## Sample Queries

Q1. Find the vertexes that 201 likes:

```
(user@127.0.0.1) [(none)]> GO FROM 201 OVER like;
nebula> GO FROM 201 OVER like;
=======
| id |
@@ -383,7 +383,7 @@ Q1. Find the vertexes that 201 likes:
Q2. Find the vertexes that 201 likes, whose age are greater than 17. Return their name, age and gender, and alias the columns as Friend, Age and Gender, respectively.

```
(user@127.0.0.1) [(none)]> GO FROM 201 OVER like WHERE $$.student.age >= 17 YIELD $$.student.name AS Friend, $$.student.age AS Age, $$.student.gender AS Gender;
nebula> GO FROM 201 OVER like WHERE $$.student.age >= 17 YIELD $$.student.name AS Friend, $$.student.age AS Age, $$.student.gender AS Gender;
=========================
| Friend | Age | Gender |
@@ -402,7 +402,7 @@ Q3. Find the selected courses and corresponding grades of students liked by 201.
```
-- By pipe
(user@127.0.0.1) [(none)]> GO FROM 201 OVER like | GO FROM $-.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
nebula> GO FROM 201 OVER like | GO FROM $-.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
=============================
| Student | Course | Grade |
@@ -415,7 +415,7 @@ Q3. Find the selected courses and corresponding grades of students liked by 201.
-----------------------------
-- By temporary variable
(user@127.0.0.1) [(none)]> $a=GO FROM 201 OVER like; GO FROM $a.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
nebula> $a=GO FROM 201 OVER like; GO FROM $a.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
=============================
| Student | Course | Grade |
@@ -20,14 +20,14 @@ Comparison operations result in a value of _true_ and _false_.
Equal. String comparisons are case-sensitive. Values of different type are not equal.

```
(user@127.0.0.1) [(none)]> YIELD 'A' == 'a';
nebula> YIELD 'A' == 'a';
==============
| ("A"=="a") |
==============
| false |
--------------
(user@127.0.0.1) [(none)]> YIELD '2' == 2;
nebula> YIELD '2' == 2;
============
| ("2"==2) |
============
@@ -40,7 +40,7 @@ Equal. String comparisons are case-sensitive. Values of different type are not e
Greater than:

```
(user@127.0.0.1) [(none)]> YIELD 3 > 2;
nebula> YIELD 3 > 2;
=========
| (3>2) |
=========
@@ -53,7 +53,7 @@ Greater than:
Greater than or equal:

```
(user@127.0.0.1) [(none)]> YIELD 2 >= 2;
nebula> YIELD 2 >= 2;
==========
| (2>=2) |
==========
@@ -66,7 +66,7 @@ Greater than or equal:
Less than:

```
(user@127.0.0.1) [(none)]> YIELD 2.0 < 1.9;
nebula> YIELD 2.0 < 1.9;
=======================
| (2.000000<1.900000) |
=======================
@@ -79,7 +79,7 @@ Less than:
Less than or equal:

```
(user@127.0.0.1) [(none)]> YIELD 0.11 <= 0.11;
nebula> YIELD 0.11 <= 0.11;
========================
| (0.110000<=0.110000) |
========================
@@ -92,7 +92,7 @@ Less than or equal:
Not equal:

```
(user@127.0.0.1) [(none)]> YIELD 1 != '1'
nebula> YIELD 1 != '1'
============
| (1!="1") |
============
@@ -1,4 +1,4 @@
| Name | Description |
| ***Name*** | ***Description*** |
|:----|:----:|
| abs() | Return the absolute value |
| acos() | Return the arc cosine |
@@ -0,0 +1,26 @@

# Aggregate (Group by) function

The `GROUP BY` functions are similar with SQL. It can only be applied in the `YIELD`-syntax.

|Name | Description |
|:----|:----:|
| AVG() | Return the average value of the argument |
| COUNT() | Return the number of records |
| COUNT(DISTINCT) | Return the number of different values |
| MAX() | Return the maximum value |
| MIN() | Return the minimum value |
| STD() | Return the population standard deviation |
| SUM() | Return the sum |

All the functions above can only applies for int64 and double.

### example

```
nebula> GO FROM 1 OVER e1 | YIELD $-.id AS fid, COUNT(*) AS cnt GROUP BY fid
-- for each fid, return the occurrence count.
nebula> GO FROM 1 YIELD e1._dst AS fid, e1.prop1 AS prop1 | YIELD fid, SUM(prop1) GROUP BY fid
-- for each fid, return the sum of prop1.
```
@@ -1,4 +1,4 @@
| Name | Description |
| ***Name*** | ***Description*** |
|:----|:----:|
| && | Logical AND |
| ! | Logical NOT |
@@ -12,7 +12,7 @@ In nGQL, nonzero numbers are evaluated to _true_. The precedence of the operator
Logical AND:

```
(user@127.0.0.1) [(none)]> YIELD -1 && true;
nebula> YIELD -1 && true;
================
| (-(1)&&true) |
================
@@ -25,7 +25,7 @@ Logical AND:
Logical NOT:

```
(user@127.0.0.1) [(none)]> YIELD !(-1);
nebula> YIELD !(-1);
===========
| !(-(1)) |
===========
@@ -39,7 +39,7 @@ Logical NOT:
Logical OR:

```
(user@127.0.0.1) [(none)]> YIELD 1 || !1;
nebula> YIELD 1 || !1;
=============
| (1||!(1)) |
=============
@@ -16,7 +16,7 @@ For operators from the same precedence level within an expression, evaluation is
Examples:

```
(user@127.0.0.1) [(none)]> YIELD 2+3*5;
(user@127.0.0.1) [(none)]> YIELD (2+3)*5;
nebula> YIELD 2+3*5;
nebula> YIELD (2+3)*5;
```

@@ -0,0 +1,22 @@
# Order By Function

Similar with SQL, `ORDER BY` can be used to sort in ascending (`ASC`) or descending (`DESC`) order for return results.
And it can only be used in the `PIEP`-syntax ("|")

```
| ORDER BY <prop> ASC | DESC [, <prop> ASC | DESC ...]
```
By default, `ORDER BY` sorts in ascending order if no ASC or DESC is given.

### Example

```
nebula> FETCH PROP ON player 1,2,3,4 YIELD player.age AS age, player.weight as weight | ORDER BY $-.age, $-.weight DESC
-- get four of vertices and sort by their age begin with the youngest one, and for those with the same age, sort by their weight.
```
(see `FETCH` for the usage)

```
nebula> GO FROM 1 OVER edge2 YIELD $^.t1.prop1 AS s1_p1, edge2.prop2 AS e2_p2, $$.t3.prop3 AS d3_p3 | ORDER BY s1_p1 ASC, e2_p2 DESC, d3_p3 ASC
```
For a group of returned tuples <s1_p1, e2_p2, d3_p3>, first sort in ascending order of s1_p1, then in descending order of e2_p2, finally ascending order of d3_p3.
@@ -1 +1,3 @@
<!---
Not supported yet
--->
@@ -8,14 +8,15 @@ Nested comments are not supported
The following example demonstrates all these comment styles:

```
(user@127.0.0.1) [(none)]> YIELD 1+1 # This comment continues to the end of line
(user@127.0.0.1) [(none)]> YIELD 1+1 -- This comment continues to the end of line
(user@127.0.0.1) [(none)]> YIELD 1+1 // This comment continues to the end of line
(user@127.0.0.1) [(none)]> YIELD 1 /* this is an in-line comment */ + 1
(user@127.0.0.1) [(none)]> YIELD 11 + \
/* Multiple-line comment \
Use backslash \
as line break. \
nebula> -- Do nothing this line
nebula> YIELD 1+1 # This comment continues to the end of line
nebula> YIELD 1+1 -- This comment continues to the end of line
nebula> YIELD 1+1 // This comment continues to the end of line
nebula> YIELD 1 /* this is an in-line comment */ + 1
nebula> YIELD 11 + \
/* Multiple-line comment \
Use backslash as line break. \
*/ 12
```
The backslash `\` at the line of line indicates a line break.

@@ -3,16 +3,16 @@ In Nebula Graph, Identifiers are case-sensitive.
The following statement would not work because it refers to a space both as 'my_space' and as 'MY_SPACE':

```
(user@127.0.0.1) [(none)]> CREATE SPACE my_space();
(user@127.0.0.1) [(none)]> use MY_SPACE;
nebula> CREATE SPACE my_space();
nebula> use MY_SPACE;
```

However, keywords and reserved words are case-insensitive.

The following statements are equivalent:
```
(user@127.0.0.1) [(none)]> show spaces;
(user@127.0.0.1) [(none)]> SHOW SPACES;
(user@127.0.0.1) [(none)]> SHOW spaces;
(user@127.0.0.1) [(none)]> show spaces;
nebula> show spaces;
nebula> SHOW SPACES;
nebula> SHOW spaces;
nebula> show spaces;
```
No changes.
@@ -1,7 +1,7 @@
The boolean literals `TRUE` and `FALSE` can be written in any lettercase.

```
(user@127.0.0.1) [(none)]> yield TRUE, true, FALSE, false, FalsE
nebula> yield TRUE, true, FALSE, false, FalsE
=========================================
|  true |  true | false | false | false |  
=========================================
@@ -1,5 +1,5 @@
<!---
>NOTICE: NULL and NOT NULL are NOT FULLY SUPPORTED YET!
The NULL value means “no data.” NULL can be written in any lettercase. Be aware that the NULL value is different from values such as 0 for interges or empty string.
The NULL value means “no data.” NULL can be written in any letter cases. Be aware that the NULL value is different from values such as 0 for interges or empty string.
--->

0 comments on commit d128868

Please sign in to comment.
You can’t perform that action at this time.