Skip to content

Commit

Permalink
update data types (#2169)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-lzy authored Jul 14, 2023
1 parent 20911da commit a91114b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
30 changes: 29 additions & 1 deletion docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ This topic will describe the `DATE`, `TIME`, `DATETIME`, `TIMESTAMP`, and `DURAT

- `date()`, `time()`, and `datetime()` all accept the property name to return a specific property value of itself. For example, `date().month` returns the current month, while `time("02:59:40").minute` returns the minutes of the importing time.

- For time operations it is recommended to use `duration()` to calculate the offset of the moment. Addition and subtraction of `date()` and `date()`, `timestamp()` and `timestamp()` are also supported.

- When setting the year of the time as a negative number, you need to use Map type data.

## OpenCypher Compatibility

In nGQL:
Expand All @@ -32,7 +36,31 @@ In nGQL:

The `DATE` type is used for values with a date part but no time part. Nebula Graph retrieves and displays `DATE` values in the `YYYY-MM-DD` format. The supported range is `-32768-01-01` to `32767-12-31`.

The properties of `date()` include `year`, `month`, and `day`.
The properties of `date()` include `year`, `month`, and `day`. `date()` supports the input of `YYYYY`, `YYYYY-MM` or `YYYYY-MM-DD`, and defaults to `01` for an untyped month or day.

```ngql
nebula> RETURN DATE({year:-123, month:12, day:3});
+------------------------------------+
| date({year:-(123),month:12,day:3}) |
+------------------------------------+
| -123-12-03 |
+------------------------------------+
nebula> RETURN DATE("23333");
+---------------+
| date("23333") |
+---------------+
| 23333-01-01 |
+---------------+
nebula> RETURN DATE("2023-12-12") - DATE("2023-12-11");
+-----------------------------------------+
| (date("2023-12-12")-date("2023-12-11")) |
+-----------------------------------------+
| 1 |
+-----------------------------------------+
```


## TIME

Expand Down
7 changes: 0 additions & 7 deletions docs-2.0/3.ngql-guide/5.operators/1.comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ NebulaGraph supports the following comparison operators.

| Name | Description |
| :---- | :----: |
| `=` | Assigns a value |
| `+` | Addition operator |
| `-` | Minus operator |
| `*` | Multiplication operator |
| `/` | Division operator |
| `==` | Equal operator |
| `!=`, `<>` | Not equal operator |
| `>` | Greater than operator |
| `>=` | Greater than or equal operator |
| `<` | Less than operator |
| `<=` | Less than or equal operator |
| `%` | Modulo operator |
| `-` | Changes the sign of the argument |
| `IS NULL` | NULL check |
| `IS NOT NULL` | Not NULL check |
| `IS EMPTY` | EMPTY check |
Expand Down
37 changes: 37 additions & 0 deletions docs-2.0/3.ngql-guide/5.operators/10.arithmetic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Arithmetic operators

NebulaGraph supports the following arithmetic operators.

| Name | Description |
| :---- | :----: |
| `+` | Addition operator |
| `-` | Minus operator |
| `*` | Multiplication operator |
| `/` | Division operator |
| `%` | Modulo operator |
| `-` | Changes the sign of the argument |

## Examples

```ngql
nebula> RETURN 1+2 AS result;
+--------+
| result |
+--------+
| 3 |
+--------+
nebula> RETURN -10+5 AS result;
+--------+
| result |
+--------+
| -5 |
+--------+
nebula> RETURN (3*8)%5 AS result;
+--------+
| result |
+--------+
| 4 |
+--------+
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ nav:
- Set: 3.ngql-guide/5.operators/6.set.md
- String: 3.ngql-guide/5.operators/7.string.md
- List: 3.ngql-guide/5.operators/8.list.md
- Arithmetic: 3.ngql-guide/5.operators/10.arithmetic.md
- Precedence: 3.ngql-guide/5.operators/9.precedence.md

- Functions and expressions:
Expand Down

0 comments on commit a91114b

Please sign in to comment.