forked from vesoft-inc/nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[user manual] add functions and operators (vesoft-inc#688)
* add functions and operators * add language structure * update table format * update * update * update * add functions and operators * add language structure * update table format * Fix use-after-free problem in BalancerPlan (vesoft-inc#684) * update * Implement leader change logic (vesoft-inc#675) * update * update * add assignment example * add functions and operators * add language structure * update table format * update * update * update * add functions and operators * update table format * update * update * update * add assignment example * merge
- Loading branch information
Showing
8 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
docs/manul_doc/Functions_and_Operators/Comparison_Functions_and_Operators.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
| Name | Description | | ||
|:----|:----:| | ||
| == | Equal operator | | ||
| > | Greater than operator | | ||
| >= | Greater than or equal operator | | ||
| < | Less than operator | | ||
| <= | Less than or equal operator | | ||
| != | Not equal operator | | ||
|
||
|
||
Comparison operations result in a value of _true_ and _false_. | ||
|
||
* == | ||
|
||
Equal. String comparisons are case-sensitive. Values of different type are not equal. | ||
|
||
``` | ||
nebula> YIELD 'A' == 'a'; | ||
============== | ||
| ("A"=="a") | | ||
============== | ||
| false | | ||
-------------- | ||
nebula> YIELD '2' == 2; | ||
============ | ||
| ("2"==2) | | ||
============ | ||
| false | | ||
------------ | ||
``` | ||
|
||
* > | ||
|
||
Greater than: | ||
|
||
``` | ||
nebula> YIELD 3 > 2; | ||
========= | ||
| (3>2) | | ||
========= | ||
| true | | ||
--------- | ||
``` | ||
|
||
* ≥ | ||
|
||
Greater than or equal: | ||
|
||
``` | ||
nebula> YIELD 2 >= 2; | ||
========== | ||
| (2>=2) | | ||
========== | ||
| true | | ||
---------- | ||
``` | ||
|
||
* < | ||
|
||
Less than: | ||
|
||
``` | ||
nebula> YIELD 2.0 < 1.9; | ||
======================= | ||
| (2.000000<1.900000) | | ||
======================= | ||
| false | | ||
----------------------- | ||
``` | ||
|
||
* ≤ | ||
|
||
Less than or equal: | ||
|
||
``` | ||
nebula> YIELD 0.11 <= 0.11; | ||
======================== | ||
| (0.110000<=0.110000) | | ||
======================== | ||
| true | | ||
------------------------ | ||
``` | ||
|
||
* != | ||
|
||
Not equal: | ||
|
||
``` | ||
nebula> YIELD 1 != '1' | ||
============ | ||
| (1!="1") | | ||
============ | ||
| true | | ||
------------ | ||
``` |
24 changes: 24 additions & 0 deletions
24
docs/manul_doc/Functions_and_Operators/Functions_and_Operator_Reference.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
| Name | Description | | ||
|:----|:----:| | ||
| abs() | Return the absolute value | | ||
| acos() | Return the arc cosine | | ||
| asin() | Return the arc sine | | ||
| atan() | Return the arc tangent | | ||
| cbrt() | Returns the cubic root of the argument | | ||
| ceil() | Return the smallest integer value not less than the argument | | ||
| cos() | Return the cosine | | ||
| exp() | Raise to the power of | | ||
| floor() | Return the largest integer value not greater than the argument | | ||
| hypot() | Returns the hypotenuse of a right-angled triangle | | ||
| log() | Return the natural logarithm of the first argument | | ||
| log2() | Return the base-2 logarithm of the argument | | ||
| log10() | Return the base-10 logarithm of the argument | | ||
| now() | Return the current date and time | | ||
| pow() | Return the argument raised to the specified power | | ||
| rand32() | Return a random 32 bit interger | | ||
| rand64() | Return a random 64 bit interger | | ||
| round() | Round the argument | | ||
| sin() | Return the sine of the argument | | ||
| sqrt() | Return the square root of the argument | | ||
| strcasecmp() | Compare strings without sensitivity to case | | ||
| tan() | Return the tangent of the argument | |
48 changes: 48 additions & 0 deletions
48
docs/manul_doc/Functions_and_Operators/Logical_Operators.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
| Name | Description | | ||
|:----|:----:| | ||
| && | Logical AND | | ||
| ! | Logical NOT | | ||
| \|\| | Logical OR | | ||
|
||
|
||
In nGQL, nonzero numbers are evaluted to _true_. The precedence of the operators refer to [Operator Precedence](./Operator_Precedence.md). | ||
|
||
* && | ||
|
||
Logical AND: | ||
|
||
``` | ||
nebula> YIELD -1 && true; | ||
================ | ||
| (-(1)&&true) | | ||
================ | ||
| true | | ||
---------------- | ||
``` | ||
|
||
* ! | ||
|
||
Logical NOT: | ||
|
||
``` | ||
nebula> YIELD !(-1); | ||
=========== | ||
| !(-(1)) | | ||
=========== | ||
| false | | ||
----------- | ||
``` | ||
|
||
* || | ||
|
||
Logical OR: | ||
|
||
``` | ||
nebula> YIELD 1 || !1; | ||
============= | ||
| (1||!(1)) | | ||
============= | ||
| true | | ||
``` | ||
|
22 changes: 22 additions & 0 deletions
22
docs/manul_doc/Functions_and_Operators/Operator_Precedence.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The following list shows the precedence of nGQL operators, in descending order. Operators on a line have the same precedence. | ||
|
||
``` | ||
! | ||
- (unary minus) | ||
*, /, % | ||
-, + | ||
== , >=, >, <=, <, <>, != | ||
&& | ||
|| | ||
= (assignment) | ||
``` | ||
|
||
For operators from the same precedence level within an expression, evaluation is from left to right, with the exception that assignment evaluates right to left. However, parentheses can be used to modify the order. | ||
|
||
Examples: | ||
|
||
``` | ||
YIELD 2+3*5; | ||
YIELD (2+3)*5; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
| Name | Description | | ||
|:----|:----| | ||
| && | Logical AND | | ||
| = | Assign a value | | ||
| \|\| | Logical OR | | ||
| / | Division operator | | ||
| == | Equal operator | | ||
| != | Not equal operator | | ||
| < | Less than operator | | ||
| <= | Less than or equal operator | | ||
| - | Minus operator | | ||
| % | Modulo operator | | ||
| + | Addition operator | | ||
| ! | Logical NOT | | ||
| * | Multiplication operator | | ||
| - | Change the sign of the argument | | ||
|
||
|
||
Example: | ||
|
||
``` | ||
nebula> $a=GO FROM 201 OVER like; GO FROM $a.id OVER select YIELD $^.student.name; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Not supported yet |
19 changes: 19 additions & 0 deletions
19
docs/manul_doc/Language_Structure/Identifier_Case_Sensitivity.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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': | ||
|
||
``` | ||
nebula> CREATE SPACE my_space(partition_num=1, replica_factor=1); | ||
nebula> use MY_SPACE; | ||
``` | ||
|
||
However, keywords and reserved words are case-insensitive. | ||
|
||
The following statements are equivalent: | ||
``` | ||
nebula> show spaces; | ||
nebula> SHOW SPACES; | ||
nebula> SHOW spaces; | ||
nebula> show spaces; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Certain objects within Nebula graph, including space, tag, edge, alias, customer variables and other object names are referred as identifiers. This section describes the rules for identifiers in Nebula Graph: | ||
|
||
* Permitted characters in identifiers: | ||
|
||
ASCII: [0-9,a-z,A-Z,_] (basic Latin letters, digits 0-9, underscore), Other punctuation characters are not supported. | ||
* All identifiers must begin with a letter of the alphabet. | ||
* Identifiers are case sensitive. | ||
* You cannot use a keyword (a reserved word) as an identifier. | ||
|