diff --git a/docs/interactive_engine/gopt.md b/docs/interactive_engine/gopt.md index d132f66c525d..524a7e1c238c 100644 --- a/docs/interactive_engine/gopt.md +++ b/docs/interactive_engine/gopt.md @@ -373,7 +373,7 @@ MATCH (a {name:'Alice'})-[b {creationDate: 20120324}]->(c {name: 'Bob'}) Return a, b, c; ``` -The rule can also be combined with other relational optimization techniques, such as Calcite’s `FilterIntoJoinRule`, which optimizes filtering after a join. For example, consider a query with multiple `MATCH` clauses followed by a filtering condition: +The rule can also be combined with other relational optimization techniques, such as Calcite’s `FilterIntoJoinRule`, which optimizes filtering based on a join operator. For example, consider a query with multiple `MATCH` clauses followed by a filtering condition: ```cypher MATCH (a)-[b]->(c) diff --git a/docs/interactive_engine/neo4j/supported_cypher.md b/docs/interactive_engine/neo4j/supported_cypher.md index b472e48c7fc0..89146fcc9c25 100644 --- a/docs/interactive_engine/neo4j/supported_cypher.md +++ b/docs/interactive_engine/neo4j/supported_cypher.md @@ -117,28 +117,32 @@ Note that some Aggregator operators, such as `max()`, we listed here are impleme | User Defined Functions | convert integer value to datetime | datetime(1287230400000) | gs.function.datetime(1287230400000) | | | ## Clause -A notable limitation for now is that we do not -allow specifying multiple `MATCH` clauses in **one** query. For example, -the following code will not compile: +Currently, we support multiple `MATCH` clauses within a single Cypher query, and the entire query can be converted into different logical plans under different circumstances. + +By default, we transform multiple `MATCH` clauses into a `Join` tree. + +For example: + ```Cypher +// phase 1 MATCH (a) -[]-> (b) WITH a, b -MATCH (a) -[]-> () -[]-> (b) # second MATCH clause + +// phase 2 +MATCH (a) -[]-> () -[]-> (b) + +// phase 3 RETURN a, b; ``` -Besides, we support `OPTIONAL MATCH`. For example, -the following query can be supported: -```Cypher -MATCH (a) -[]-> (b) -Optional MATCH (b) -[]-> (c) -RETURN a, b, c; -``` +In this case, an `INNER JOIN` operator is used to combine the results from the first two phases, with phase 1 as the left input and phase 2 as the right input. This works similarly for `OPTIONAL MATCH` clauses, except that the join type would be a `LEFT OUTER JOIN` instead of an `INNER JOIN`. + +If the `FlatJoinToExpandRule` is registered, the `Join` operator will be eliminated, and the query will be transformed into a sequence of `Expand` and `GetV` operators, while preserving the execution order specified by the user. For more details, see [GOpt](../gopt.md#flatjointoexpandrule). | Keyword | Comments | Supported | Todo |:---|---|:---:|:---| -| MATCH | only one Match clause is allowed | | -| OPTIONAL MATCH | implements as left outer join | | | +| MATCH | description about a graph pattern | | +| OPTIONAL MATCH | implements as left outer join by default | | | | RETURN .. [AS] | | | | | WITH .. [AS] | project, aggregate, distinct | | | | WHERE | | | | @@ -146,6 +150,7 @@ RETURN a, b, c; | ORDER BY | | | | | LIMIT | | | | | UNFOLD | The operation is similar to SQL's 'UNSET', as it unfolds elements from a collection type | | | +| UNION CALL | merge the results from different branches, with each branch represented by a `CALL` operator | | | Additionally, we support two types of procedure call invocations in Cypher: - We offer a set of built-in procedures that can be invoked directly within Cypher queries. These procedures are all prefixed with `gs.procedure.`.