alibaba / alibaba/GraphScope

feature(interactive): Unify the Conversion for `where subquery` in both Gremlin and Cypher.

Open
#3,766 0 comments 0 reactions 1 assignee Claimed by @shirly121 View on GitHub
component:gie
Dominant language
C++
Stars
3.6k
Forks
468
Avg merge
29m
Merged PRs (30d)
1

Description

There's currently an inconsistency in handling `where subquery` between the Cypher and Gremlin.
Specifically, for the following Gremlin query:
```
g.V().as('a').out().out().as('b').where(as('b').out().as('a'))
```
This query is transformed into an `apply` operation in Gremlin.

The equivalent Cypher query:
```
MATCH (a)-[]->()-[]-(b)
WHERE (b)-[]->(a)
```
is transformed into a `semi-join` with two `Match`, `Match (a)-[]->()-[]-(b)` Semi-Join `Match (b)-[]->(a)`, in Cypher.

**Solution**

Provide a unified API through `GraphBuilder` to convert the following queries respectively into their corresponding Calcite-Based IR joins:
1. Transform `where subquery` into a semi-join.
2. `where not subquery` into an anti-join.

Apply unified optimizations at the Calcite-Based IR layer:
1. Extract the common pattern to avoid duplicated computation.
2. Implement more advanced equivalent transformations, e.g., `g.V().out().where(out()) -> g.V().out().as('a').out().select('a').dedup()`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.