|
| 1 | +# Cypher Support |
| 2 | +This document outlines the current capabilities of GIE in supporting Neo4j's Cypher queries and |
| 3 | +compares them to the [syntax](https://neo4j.com/docs/cypher-manual/current/syntax/) specified in Neo4j. |
| 4 | +While our goal is to comply with Neo4j's syntax, GIE currently has some limitations. |
| 5 | +One major constraint is that we solely support the **read** path in Cypher. |
| 6 | +Therefore, functionalities associated with writing, such as adding vertices/edges or modifying their properties, remain **unaddressed**. |
| 7 | + |
| 8 | +We provide in-depth details regarding Cypher's support in GIE, mainly including data types, operators and clauses. |
| 9 | +We further highlight planned features that we intend to offer in the near future. |
| 10 | +While all terminologies, including data types, operators, and keywords in clauses, are case-insensitive in this document, we use capital and lowercase letters for the terminologies of Neo4j and GIE, respectively, to ensure clarity. |
| 11 | + |
| 12 | +## Data Types |
| 13 | +As [Neo4j](https://neo4j.com/docs/cypher-manual/current/values-and-types), we have provided support for |
| 14 | +data value of types in the categories of **property**, **structural** and **constructed**. |
| 15 | +However, the specific data types that we support are slightly modified from those in Cypher to ensure compatibility with our storage system. Further details will be elaborated upon. |
| 16 | + |
| 17 | +### Property Types |
| 18 | +The available data types stored in the vertices (equivalent of nodes in Cypher) and edges (equivalent of relationships in Cypher), known as property types, are divided into several categories including Boolean, Integer, Float, String, Bytes, Placeholder and Temporal. These property types are extensively utilized and can be commonly utilized in queries and as parameters -- making them the most commonly used data types. |
| 19 | + |
| 20 | +| Category | Cypher Type | GIE Type | Supported | Todo | |
| 21 | +|:---|:---|:---|:---:|:---| |
| 22 | +| Boolean | BOOLEAN | bool | <input type="checkbox" disabled checked /> | | |
| 23 | +| Integer | INTEGER | int32/uint32/int64/uint64 | <input type="checkbox" disabled checked /> | | |
| 24 | +| Float | FLOAT | float/double | <input type="checkbox" disabled checked /> | | |
| 25 | +| String | STRING | string | <input type="checkbox" disabled checked /> | | |
| 26 | +| Bytes| BYTE_ARRAY | bytes | <input type="checkbox" disabled checked /> | | |
| 27 | +| Placeholder | NULL | none | <input type="checkbox" disabled /> | Planned | |
| 28 | +| Temporal | DATE | date | <input type="checkbox" disabled /> | Planned | |
| 29 | +| Temporal | DATETIME (ZONED) | datetime (Zoned) | <input type="checkbox" disabled /> | Planned | |
| 30 | +| Temporal | TIME (ZONED) | time (Zoned) | <input type="checkbox" disabled /> | Planned | |
| 31 | + |
| 32 | +### Structural types |
| 33 | +In a graph, Structural Types are the first-class citizens and are comprised of the following: |
| 34 | +- Vertex: It encodes the information of a particular vertex in the graph. The information includes the id, label, and a map of properties. However, it is essential to note that multiple labels in a vertex are currently unsupported in GIE. |
| 35 | +- Edge: It encodes the information of a particular edge in the graph. The information comprises the id, edge label, a map of properties, and a pair of vertex ids that refer to source/destination vertices. |
| 36 | +- Path: It encodes the alternating sequence of vertices and conceivably edges while traversing the graph. |
| 37 | + |
| 38 | +|Category | Cypher Type | GIE Type | Supported | Todo | |
| 39 | +|:---|:---|:---|:---:|:---| |
| 40 | +|Graph | NODE | vertex | <input type="checkbox" disabled checked /> | | |
| 41 | +|Graph | RELATIONSHIP | edge | <input type="checkbox" disabled checked /> | | |
| 42 | +|Graph | PATH | path | <input type="checkbox" disabled checked /> | | |
| 43 | + |
| 44 | +### Constructed Types |
| 45 | +Constructed types mainly include the categories of Array and Map. |
| 46 | + |
| 47 | +| Category | Cypher Type | GIE Type | Supported | Todo | |
| 48 | +|:---|:---|:---|:---:|:---| |
| 49 | +| Array | LIST<INNER_TYPE> | int32/int64/double/string/pair Array | <input type="checkbox" disabled checked /> | | |
| 50 | +| Map | MAP | N/A | <input type="checkbox" disabled />| only used in Vertex/Edge | |
| 51 | + |
| 52 | +## Operators |
| 53 | +We list GIE's support of the operators in the categories of Aggregation, Property, Mathematical, |
| 54 | +Comparison, String and Boolean. Examples and functionalities of these operators are the same |
| 55 | +as in [Neo4j](https://neo4j.com/docs/cypher-manual/current/syntax/operators/). |
| 56 | +Note that some Aggregator operators, such as `max()`, we listed here are implemented in Neo4j as |
| 57 | +[functions](https://neo4j.com/docs/cypher-manual/current/functions/). We have not introduced functions at this moment. |
| 58 | + |
| 59 | + |
| 60 | +| Category | Description | Cypher Operation | GIE Operation | Supported | Todo | |
| 61 | +|:---|:----|:---|:----|:---:|:---| |
| 62 | +| Aggregate | Average value | AVG() | avg() | <input type="checkbox" disabled checked /> | | |
| 63 | +| Aggregate | Minimum value | MIN() | min() | <input type="checkbox" disabled checked /> | | |
| 64 | +| Aggregate | Maximum value |MAX() | max() | <input type="checkbox" disabled checked /> | | |
| 65 | +| Aggregate | Count the elements |COUNT() | count() | <input type="checkbox" disabled checked /> | | |
| 66 | +| Aggregate | Count the distinct elements | COUNT(DISTINCT) | count(distinct) | <input type="checkbox" disabled checked /> | | |
| 67 | +| Aggregate | Summarize the value | SUM() | sum() | <input type="checkbox" disabled checked /> | | |
| 68 | +| Aggregate | Collect into a list | COLLECT() | collect() | <input type="checkbox" disabled checked /> | | |
| 69 | +| Aggregate | Collect into a set | COLLECT(DISTINCT) | collect(distinct) | <input type="checkbox" disabled checked /> | | |
| 70 | +| Property | Get property of a vertex/edge | [N\|R]."KEY" | [v\|e]."key" | <input type="checkbox" disabled checked /> | | |
| 71 | +| Mathematical | Addition | + | + | <input type="checkbox" disabled checked /> | | |
| 72 | +| Mathematical | Subtraction | - | - | <input type="checkbox" disabled checked /> | | |
| 73 | +| Mathematical | Multiplication | * | * | <input type="checkbox" disabled checked /> | | |
| 74 | +| Mathematical | Division | / | / | <input type="checkbox" disabled checked /> | | |
| 75 | +| Mathematical | Modulo division | % | % | <input type="checkbox" disabled checked /> | | |
| 76 | +| Mathematical | Exponentiation | ^ | ^^ | <input type="checkbox" disabled checked /> | | |
| 77 | +| Comparison | Equality | = | = | <input type="checkbox" disabled checked /> | | |
| 78 | +| Comparison | Inequality| <> | <> | <input type="checkbox" disabled checked /> | | |
| 79 | +| Comparison | Less than | < | < | <input type="checkbox" disabled checked /> | | |
| 80 | +| Comparison | Less than or equal | <= | <= | <input type="checkbox" disabled checked /> | | |
| 81 | +| Comparison | Greater than | > | > | <input type="checkbox" disabled checked /> | | |
| 82 | +| Comparison | Greater than or equal | >= | >= | <input type="checkbox" disabled checked /> | | |
| 83 | +| Comparison | Verify as `NULL`| IS NULL | is null | <input type="checkbox" disabled /> | planned | |
| 84 | +| Comparison | Verify as `NOT NULL`| IS NOT NULL | is not null | <input type="checkbox" disabled /> | planned | |
| 85 | +| Comparison | String starts with | STARTS WITH | starts with | <input type="checkbox" disabled />| planned | |
| 86 | +| Comparison | String ends with | ENDS WITH | ends with | <input type="checkbox" disabled />| planned | |
| 87 | +| Comparison | String contains | CONTAINS | contains | <input type="checkbox" disabled />| planned | |
| 88 | +| Boolean | Conjunction | AND | and | <input type="checkbox" disabled checked /> | | |
| 89 | +| Boolean | Disjunction | OR | or | <input type="checkbox" disabled checked /> | | |
| 90 | +| Boolean | Exclusive Disjunction | XOR | xor | <input type="checkbox" disabled /> | planned | |
| 91 | +| Boolean | Negation | NOT | not | <input type="checkbox" disabled /> | planned | |
| 92 | +| BitOpr | Bit and | via function | & | <input type="checkbox" disabled checked /> | | |
| 93 | +| BitOpr | Bit or | via function | \| | <input type="checkbox" disabled checked /> | | |
| 94 | +| Boolean | Bit xor | via function | ^ | <input type="checkbox" disabled checked /> | | |
| 95 | +| BitOpr | Bit reverse | via function | ~ | <input type="checkbox" disabled checked /> | | |
| 96 | +| BitOpr | Bit left shift | via function | << | <input type="checkbox" disabled />| planned | |
| 97 | +| BitOpr | Bit right shift | via function | >> | <input type="checkbox" disabled />| planned | |
| 98 | +| Branch | Use with `Project` and `Return` | CASE WHEN | CASE WHEN | <input type="checkbox" disabled />| planned | |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +## Clause |
| 103 | +A notable limitation for now is that we do not |
| 104 | +allow specifying multiple `MATCH` clauses in **one** query. For example, |
| 105 | +the following code will not compile: |
| 106 | +```Cypher |
| 107 | +MATCH (a) -[]-> (b) |
| 108 | +WITH a, b |
| 109 | +MATCH (a) -[]-> () -[]-> (b) # second MATCH clause |
| 110 | +RETURN a, b; |
| 111 | +``` |
| 112 | + |
| 113 | +| Keyword | Comments | Supported | Todo |
| 114 | +|:---|---|:---:|:---| |
| 115 | +| MATCH | only one Match clause is allowed | <input type="checkbox" disabled checked /> | |
| 116 | +| OPTIONAL MATCH | implements as left outer join | <input type="checkbox" disabled /> | planned | |
| 117 | +| RETURN .. [AS] | | <input type="checkbox" disabled checked /> | | |
| 118 | +| WITH .. [AS] | project, aggregate, distinct | <input type="checkbox" disabled checked /> | | |
| 119 | +| WHERE | | <input type="checkbox" disabled checked /> | | |
| 120 | +| NOT EXIST (an edge/path) | implements as anti join | <input type="checkbox" disabled />| | |
| 121 | +| ORDER BY | | <input type="checkbox" disabled checked /> | | |
| 122 | +| LIMIT | | <input type="checkbox" disabled checked /> | | |
| 123 | + |
0 commit comments