Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions doc/source/cypher_manual/data_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ The following table showcases all data types supported by NeuG and their differe

| Category | Type | System Default value | NeuG Example | Neo4j Example |
|----------|------|---------------------|--------------|---------------|
| Primitive | INT32 | `0` | `Return CAST(42, 'INT32')` | `Return 42` |
| Primitive | UINT32 | `0` | `Return CAST(42, 'UINT32')` | unsupported |
| Primitive | INT64 | `0` | `Return 9223372036854775807` | `Return 9223372036854775807` |
| Primitive | UINT64 | `0` | `Return CAST(9223372036854775807, 'UINT64')` | unsupported |
| Primitive | FLOAT | `0.0` | `Return CAST(3.14, 'FLOAT')` | `Return 3.14f` |
| Primitive | DOUBLE | `0.0` | `Return 3.14159265359` | `Return 3.14159265359d` |
| Primitive | BOOL | `false` | `Return true` | `Return true` |
| Primitive | NULL | `null` | `Return null` | `Return null` |
| String | VARCHAR | `''` (empty string) | `Return 'Hello World'` | `Return 'Hello World'` |
| Temporal | DATE | `1970-01-01` | `Return date('2022-06-06')` | `Return date('2022-06-06')` |
| Temporal | DATETIME | `1970-01-01 00:00:00` | `Return timestamp('2022-06-06 12:00:00')` | `Return datetime('2022-06-06T12:00:00')` |
| Temporal | INTERVAL | `0 year 0 month 0 day` (zero interval) | `RETURN interval('1 year 2 month 3 day')` | `Return duration('P1Y2M3D')` |
| Composite | LIST | `[]` (empty list) | `Return [1, 2, 3]` | `Return [1, 2, 3]` |
| Pattern | NODE | `{}` (empty node) | `{_ID: 0, _LABEL: person, id: 1, name: marko, age: 29}` | `(:person {name: 'Alice', age: 30})` |
| Pattern | REL | `{}` (empty edge) | `{_ID: 2, _LABEL: knows, _SRC_LABEL: person, _DST_LABEL: person, _SRC_ID: 0, _DST_ID: 2, weight: 1.0}` | `[:knows {weight: 1.0}]` |
| Pattern | REPEATED PATH | `[]` (empty path) | `{_ID: 0, _LABEL: person}, {_ID: 4294967298, _LABEL: created, _SRC_LABEL: person, _DST_LABEL: person, _SRC_ID: 0, _DST_ID: 2}, {_ID: 2, _LABEL: person}, {_ID: 4297064449, _LABEL: created, _SRC_LABEL: person, _DST_LABEL: software, _SRC_ID: 2, _DST_ID: 72057594037927937}, {_ID: 72057594037927937, _LABEL: software}` | `(:Person {name: "Kiefer", id: 4, age: 1992})-[:FOLLOWS]->(:Person {name: "Jack", id: 3, age: 1979})-[:FOLLOWS]->(:Person {name: "Kevin", id: 5, age: 1997})` |
| Primitive | INT32 | `0` | `RETURN CAST(42, 'INT32')` | `RETURN 42` |
| Primitive | UINT32 | `0` | `RETURN CAST(42, 'UINT32')` | unsupported |
| Primitive | INT64 | `0` | `RETURN 9223372036854775807` | `RETURN 9223372036854775807` |
| Primitive | UINT64 | `0` | `RETURN CAST(9223372036854775807, 'UINT64')` | unsupported |
| Primitive | FLOAT | `0.0` | `RETURN CAST(3.14, 'FLOAT')` | `RETURN 3.14f` |
| Primitive | DOUBLE | `0.0` | `RETURN 3.14159265359` | `RETURN 3.14159265359d` |
| Primitive | BOOL | `false` | `RETURN true` | `RETURN true` |
| Primitive | NULL | `null` | `RETURN null` | `RETURN null` |
| String | VARCHAR | `''` (empty string) | `RETURN 'Hello World'` | `RETURN 'Hello World'` |
| Temporal | DATE | `1970-01-01` | `RETURN date('2022-06-06')` | `RETURN date('2022-06-06')` |
| Temporal | DATETIME | `1970-01-01 00:00:00` | `RETURN timestamp('2022-06-06 12:00:00')` | `RETURN datetime('2022-06-06T12:00:00')` |
| Temporal | INTERVAL | `0 year 0 month 0 day` (zero interval) | `RETURN interval('1 year 2 month 3 day')` | `RETURN duration('P1Y2M3D')` |
| Composite | LIST | `[]` (empty list) | `RETURN [1, 2, 3]` | `RETURN [1, 2, 3]` |
| Pattern | NODE | `{}` (empty node) | `{_ID: 0, _LABEL: Person, id: 1, name: marko, age: 29}` | `(:Person {name: 'Alice', age: 30})` |
| Pattern | REL | `{}` (empty edge) | `{_ID: 2, _LABEL: KNOWS, _SRC_LABEL: Person, _DST_LABEL: Person, _SRC_ID: 0, _DST_ID: 2, weight: 1.0}` | `[:KNOWS {weight: 1.0}]` |
| Pattern | REPEATED PATH | `[]` (empty path) | `{_ID: 0, _LABEL: Person}, {_ID: 4294967298, _LABEL: CREATED, _SRC_LABEL: Person, _DST_LABEL: Person, _SRC_ID: 0, _DST_ID: 2}, {_ID: 2, _LABEL: Person}, {_ID: 4297064449, _LABEL: CREATED, _SRC_LABEL: Person, _DST_LABEL: Software, _SRC_ID: 2, _DST_ID: 72057594037927937}, {_ID: 72057594037927937, _LABEL: Software}` | `(:Person {name: "Kiefer", id: 4, age: 1992})-[:FOLLOWS]->(:Person {name: "Jack", id: 3, age: 1979})-[:FOLLOWS]->(:Person {name: "Kevin", id: 5, age: 1997})` |

## Detailed Introduction

Expand All @@ -32,7 +32,7 @@ The following table showcases all data types supported by NeuG and their differe
#### INT32
- **Description**: 32-bit signed integer type
- **Range**: [2,147,483,648, 2,147,483,647]
- **Query Example**: `Return CAST(42, 'INT32') as int32_value;`
- **Query Example**: `RETURN CAST(42, 'INT32') AS int32_value;`

#### UINT32
- **Description**: 32-bit unsigned integer type
Expand Down Expand Up @@ -123,12 +123,12 @@ RETURN ['marko', 2];

Combining different property types from nodes in a list:
```cypher
MATCH (n:person) RETURN [n.name, n.age];
MATCH (n:Person) RETURN [n.name, n.age];
```

Supporting nested list structures:
```cypher
MATCH (n:person) RETURN [["name", n.name], ["age", n.age]];
MATCH (n:Person) RETURN [["name", n.name], ["age", n.age]];
```

**Key Technical Details:**
Expand All @@ -143,17 +143,17 @@ MATCH (n:person) RETURN [["name", n.name], ["age", n.age]];
#### NODE
- **Description**: Represents a node in the graph
- **Internal Structure** (order is insignificant): `_ID` (internal identifier), `_LABEL` (indication of node type) and property fields
- **Query Example**: `MATCH (n:person) RETURN n AS node_value;`
- **NeuG Format**: `{_ID: 0, _LABEL: person, id: 1, name: marko, age: 29}`
- **Query Example**: `MATCH (n:Person) RETURN n AS node_value;`
- **NeuG Format**: `{_ID: 0, _LABEL: Person, id: 1, name: marko, age: 29}`

#### REL (Edge)
- **Description**: Represents an edge in the graph
- **Internal Structure** (order is insignificant): `_ID` (edge internal identifier), `_LABEL` (indication of edge type), `_SRC_ID` (internal identifier of source node), `_SRC_LABEL` (label of source node), `_DST_ID` (internal identifier of destination node), `_DST_LABEL` (label of destination node), and property fields
- **Query Example**: `MATCH ()-[r:knows]->() RETURN r AS rel_value;`
- **NeuG Format**: `{_ID: 2, _LABEL: knows, _SRC_ID: 0, _SRC_LABEL: person, _DST_ID: 2, _DST_LABEL: person, weight: 1.0}`
- **Query Example**: `MATCH ()-[r:KNOWS]->() RETURN r AS rel_value;`
- **NeuG Format**: `{_ID: 2, _LABEL: KNOWS, _SRC_ID: 0, _SRC_LABEL: Person, _DST_ID: 2, _DST_LABEL: Person, weight: 1.0}`

#### PATH
- **Description**: Represents a graph path formed by alternating nodes and edges.
- **Internal Structure**: An **ordered sequence** of nodes and edges along the path, including the starting and ending nodes.
- **Query Example**: `MATCH (a:person)-[p*1..2]->(c) RETURN p AS path_value;`
- **NeuG Format**: `{_ID: 0, _LABEL: person}, {_ID: 4294967298, _LABEL: created, _SRC_LABEL: person, _DST_LABEL: person, _SRC_ID: 0, _DST_ID: 2}, {_ID: 2, _LABEL: person}, {_ID: 4297064449, _LABEL: created, _SRC_LABEL: person, _DST_LABEL: software, _SRC_ID: 2, _DST_ID: 72057594037927937}, {_ID: 72057594037927937, _LABEL: software}`
- **Query Example**: `MATCH (a:Person)-[p*1..2]->(c) RETURN p AS path_value;`
- **NeuG Format**: `{_ID: 0, _LABEL: Person}, {_ID: 4294967298, _LABEL: CREATED, _SRC_LABEL: Person, _DST_LABEL: Person, _SRC_ID: 0, _DST_ID: 2}, {_ID: 2, _LABEL: Person}, {_ID: 4297064449, _LABEL: CREATED, _SRC_LABEL: Person, _DST_LABEL: Software, _SRC_ID: 2, _DST_ID: 72057594037927937}, {_ID: 72057594037927937, _LABEL: Software}`
46 changes: 23 additions & 23 deletions doc/source/cypher_manual/ddl_clause.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ Please refer to the following examples for more usages.

## Create Node Type

Create a node with Label type "person", specifying the property names, types, and primary key for the person.
Create a node with Label type "Person", specifying the property names, types, and primary key for the Person.

```
CREATE NODE TABLE person (
CREATE NODE TABLE Person (
name STRING,
age INT32,
PRIMARY KEY (name)
);
```

By default, if a person type already exists in the database, an error will be reported. Use IF NOT EXISTS to avoid errors - it will only create if the type doesn't exist in the database, otherwise it will do nothing.
By default, if a Person type already exists in the database, an error will be reported. Use IF NOT EXISTS to avoid errors - it will only create if the type doesn't exist in the database, otherwise it will do nothing.

```
CREATE NODE TABLE IF NOT EXISTS person (
CREATE NODE TABLE IF NOT EXISTS Person (
name STRING,
age INT32,
PRIMARY KEY (name)
Expand All @@ -43,11 +43,11 @@ CREATE NODE TABLE IF NOT EXISTS person (

## Create Edge Type

Create an edge of type "knows" from person to person, specifying the property names and types for knows. Currently, edges do not support specifying primary keys.
Create an edge of type "KNOWS" from Person to Person, specifying the property names and types for KNOWS. Currently, edges do not support specifying primary keys.

```
CREATE REL TABLE IF NOT EXISTS knows (
FROM person TO person,
CREATE REL TABLE IF NOT EXISTS KNOWS (
FROM Person TO Person,
weight DOUBLE
);
```
Expand All @@ -56,11 +56,11 @@ CREATE REL TABLE IF NOT EXISTS knows (

Optionally, you can add exactly one *multiplicity* token after the last column definition (and a comma), before the closing `)` of the `CREATE REL TABLE` header. It describes cardinality along the forward direction (from source to target). Allowed values are `ONE_TO_ONE`, `ONE_TO_MANY`, `MANY_TO_ONE`, and `MANY_TO_MANY`. If you omit it, the edge type uses `MANY_TO_MANY` by default.

For example, on the same `person` / `knows` / `weight` shape as above:
For example, on the same `Person` / `KNOWS` / `weight` shape as above:

```
CREATE REL TABLE IF NOT EXISTS knows (
FROM person TO person,
CREATE REL TABLE IF NOT EXISTS KNOWS (
FROM Person TO Person,
weight DOUBLE,
MANY_TO_MANY
);
Expand All @@ -70,11 +70,11 @@ CREATE REL TABLE IF NOT EXISTS knows (

You can append a `WITH ( … )` clause *after* the closing `)` of the table header. Inside the parentheses, pass one or more options as `name = value`, where values are literals. A common key is `sort_key_for_nbr`, whose value is typically a string literal naming an edge property used for ordering. The clause is optional.

Example, still with `person`, `knows`, and `weight` only—here `weight` is used as the sort column name:
Example, still with `Person`, `KNOWS`, and `weight` only—here `weight` is used as the sort column name:

```
CREATE REL TABLE IF NOT EXISTS knows (
FROM person TO person,
CREATE REL TABLE IF NOT EXISTS KNOWS (
FROM Person TO Person,
weight DOUBLE
) WITH (sort_key_for_nbr = 'weight');
```
Expand All @@ -88,49 +88,49 @@ Multiplicity and `WITH` options are defined at **edge type** scope (the edge nam
Delete a specified Node type. Use IF EXISTS to avoid errors when the type doesn't exist.

```
DROP TABLE IF EXISTS person;
DROP TABLE IF EXISTS Person;
```

## Drop Edge Type

Delete a specified Edge type. Use IF EXISTS to avoid errors when the type doesn't exist.

```
DROP TABLE IF EXISTS knows;
DROP TABLE IF EXISTS KNOWS;
```

## Rename Node or Edge Type

Rename a node or edge type by `RENAME TO`.

```
ALTER TABLE person RENAME TO person2;
ALTER TABLE knows RENAME TO knows2;
ALTER TABLE Person RENAME TO Person2;
ALTER TABLE KNOWS RENAME TO KNOWS2;
```

## Add Property

Add properties to a node or edge type.

```
ALTER TABLE person ADD IF NOT EXISTS gender INT32;
ALTER TABLE knows ADD IF NOT EXISTS info STRING;
ALTER TABLE Person ADD IF NOT EXISTS gender INT32;
ALTER TABLE KNOWS ADD IF NOT EXISTS info STRING;
```

## Drop Property

Remove properties from a node or edge type.

```
ALTER TABLE person DROP IF EXISTS gender;
ALTER TABLE knows DROP IF EXISTS info;
ALTER TABLE Person DROP IF EXISTS gender;
ALTER TABLE KNOWS DROP IF EXISTS info;
```

## Rename Property

Rename properties of a node or edge type.

```
ALTER TABLE person RENAME age TO age2;
ALTER TABLE knows RENAME weight TO weight2;
ALTER TABLE Person RENAME age TO age2;
ALTER TABLE KNOWS RENAME weight TO weight2;
```
10 changes: 5 additions & 5 deletions doc/source/cypher_manual/dml_clause.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The SET clause is used to update properties of existing nodes and edges.
Update properties of a specific node.

```cypher
MATCH (a:person)
MATCH (a:Person)
WHERE a.name = 'marko'
SET a.age = 37, a.city = 'New York'
RETURN a.*
Expand All @@ -91,7 +91,7 @@ RETURN a.*
Update properties of a specific edge.

```cypher
MATCH (a:person)-[k:knows]->(b:person)
MATCH (a:Person)-[k:KNOWS]->(b:Person)
WHERE a.name = 'marko' AND b.name = 'josh'
SET k.weight = 10.0, k.since = '2023-01-01'
RETURN k.*
Expand All @@ -106,7 +106,7 @@ The DELETE clause is used to remove nodes and edges from the graph.
Delete a node from the graph. By default, you can only delete nodes that have no edge to avoid creating dangling edges.

```cypher
MATCH (a:person)
MATCH (a:Person)
WHERE a.name = 'marko'
DELETE a
```
Expand All @@ -116,7 +116,7 @@ DELETE a
Use DETACH DELETE to forcibly delete a node and all its attached edges. This prevents errors when trying to delete nodes that have existing edges.

```cypher
MATCH (a:person)
MATCH (a:Person)
WHERE a.name = 'marko'
DETACH DELETE a
```
Expand All @@ -126,7 +126,7 @@ DETACH DELETE a
Delete specific edges between nodes while keeping the nodes.

```cypher
MATCH (a:person)-[k:knows]->(b:person)
MATCH (a:Person)-[k:KNOWS]->(b:Person)
WHERE a.name = 'marko' AND b.name = 'josh'
DELETE k
```
12 changes: 6 additions & 6 deletions doc/source/cypher_manual/expression/agg_func.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Aggregate Functions are primarily used to group current data and perform aggrega

Function | Description | Can be used with DISTINCT | Example
---------|-------------|---------------------------|--------
count | return the row counts | YES | Return count (a.name);
collect | collect the elements in a single list | YES | Return collect(a.name);
min | return the minimum value | NO | Return min(a.age);
max | return the maximum value | NO | Return max(a.age);
sum | sum up the value | NO | Return sum(a.age);
avg | return the average value | NO | Return avg(a.age);
count | return the row counts | YES | RETURN count(a.name);
collect | collect the elements in a single list | YES | RETURN collect(a.name);
min | return the minimum value | NO | RETURN min(a.age);
max | return the maximum value | NO | RETURN max(a.age);
sum | sum up the value | NO | RETURN sum(a.age);
avg | return the average value | NO | RETURN avg(a.age);
10 changes: 5 additions & 5 deletions doc/source/cypher_manual/expression/arithmetic_op.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ The following table details the error types that each operator may encounter:

| Operator | Overflow | Underflow | DivideByZero | Example |
|----------|----------|-----------|--------------|---------|
| + | YES | YES | N/A | Return CAST(2147483647, 'int32') + CAST(1, 'int32') |
| - | YES | YES | N/A | Return CAST(-2147483648, 'int32') - CAST(1, 'int32') |
| * | YES | YES | N/A | Return CAST(2147483647, 'int32') * CAST(2, 'int32') |
| / | NO | NO | YES | Return 5 / 0 |
| % | NO | NO | YES | Return 5 % 0 |
| + | YES | YES | N/A | RETURN CAST(2147483647, 'int32') + CAST(1, 'int32') |
| - | YES | YES | N/A | RETURN CAST(-2147483648, 'int32') - CAST(1, 'int32') |
| * | YES | YES | N/A | RETURN CAST(2147483647, 'int32') * CAST(2, 'int32') |
| / | NO | NO | YES | RETURN 5 / 0 |
| % | NO | NO | YES | RETURN 5 % 0 |

## Date Arithmetic

Expand Down
20 changes: 10 additions & 10 deletions doc/source/cypher_manual/expression/graph_func.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ In addition to the various relational data-based function operations introduced

Function | Description | Example
---------|-------------|--------
ID() | Get the Internal ID of a node/edge | Return (a) Return ID(a)
LABEL()/LABELS() | Get the label of a node/edge | Match (a) Return LABEL(a)
ID() | Get the Internal ID of a node/edge | MATCH (a) RETURN ID(a)
LABEL()/LABELS() | Get the label of a node/edge | MATCH (a) RETURN LABEL(a)

## Edge Function

In addition to ID and LABEL functions, there are the following edge-based function operations:

Function | Description | Example
---------|-------------|--------
START_NODE() | Returns the starting node of edge data | Match ()-[b]->() Return START_NODE(b);
END_NODE() | Returns the ending node of edge data | Match ()-[b]->() Return END_NODE(b);
START_NODE() | Returns the starting node of edge data | MATCH ()-[b]->() RETURN START_NODE(b);
END_NODE() | Returns the ending node of edge data | MATCH ()-[b]->() RETURN END_NODE(b);

## Repeated Path Function

Function | Description | Example
---------|-------------|--------
NODES | Returns all nodes from a path | Match (a)-[b*2..3]->() Return NODES(b);
RELS | Returns all edges from a path | Match (a)-[b*2..3]->() Return RELS(b);
PROPERTIES | Returns given property from nodes/edges | Match (a)-[b*2..3]->() Return PROPERTIES(nodes(b), 'name'), PROPERTIES(rels(b), 'weight');
IS_TRAIL | Checks if path contains repeated edges (`true` if no) | Match (a)-[b*2..3]->() Return IS_TRAIL(b);
IS_ACYCLIC | Checks if path contains repeated nodes (`true` if no) | Match (a)-[b*2..3]->() Return IS_ACYCLIC(b);
LENGTH | Returns the length of a path | Match (a)-[b*2..3]->() Return LENGTH(b);
NODES | Returns all nodes from a path | MATCH (a)-[b*2..3]->() RETURN NODES(b);
RELS | Returns all edges from a path | MATCH (a)-[b*2..3]->() RETURN RELS(b);
PROPERTIES | Returns given property from nodes/edges | MATCH (a)-[b*2..3]->() RETURN PROPERTIES(nodes(b), 'name'), PROPERTIES(rels(b), 'weight');
IS_TRAIL | Checks if path contains repeated edges (`true` if no) | MATCH (a)-[b*2..3]->() RETURN IS_TRAIL(b);
IS_ACYCLIC | Checks if path contains repeated nodes (`true` if no) | MATCH (a)-[b*2..3]->() RETURN IS_ACYCLIC(b);
LENGTH | Returns the length of a path | MATCH (a)-[b*2..3]->() RETURN LENGTH(b);
Loading
Loading