Skip to content

Commit

Permalink
[GIE Compiler] Fix query params of getV base in path expand operator (#…
Browse files Browse the repository at this point in the history
…2773)

<!--
Thanks for your contribution! please review
https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before
opening an issue.
-->

## What do these changes do?
In the cypher statement `(a:person)-[b:knows]-(c:person)` that
represents a path expansion, the logical plan includes two `getV`
operators. One is `getV` base inner the `path_expand` b, another is the
`endV` operator following the b. It's important to note that these
operators have different query parameters.

The `getV` base can retrieve vertices of any type that are adjacent to
the type specified in the `path_expand` operation. **This pr
specifically addresses this requirement**. The `endV` operator is
constrained by the type specified in the given query.
<!-- Please give a short brief about these changes. -->

## Related issue number

<!-- Are there any issues opened that will be resolved by merging this
change? -->

Fixes

Co-authored-by: Longbin Lai <longbin.lailb@alibaba-inc.com>
  • Loading branch information
shirly121 and longbinlai committed Jun 7, 2023
1 parent e28faa9 commit ec218cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.alibaba.graphscope.cypher.antlr4.visitor;

import com.alibaba.graphscope.common.ir.tools.config.ExpandConfig;
import com.alibaba.graphscope.common.ir.tools.config.GetVConfig;
import com.alibaba.graphscope.common.ir.tools.config.LabelConfig;
import com.alibaba.graphscope.common.ir.tools.config.PathExpandConfig;
import com.alibaba.graphscope.grammar.CypherGSBaseVisitor;
import com.alibaba.graphscope.grammar.CypherGSParser;
Expand Down Expand Up @@ -52,7 +54,10 @@ public PathExpandConfig.Builder visitOC_RelationshipPattern(
@Override
public PathExpandConfig.Builder visitOC_NodePattern(CypherGSParser.OC_NodePatternContext ctx) {
// set getV base in path_expand
return builder.getV(Utils.getVConfig(ctx));
GetVConfig getVConfig = Utils.getVConfig(ctx);
// labelConfig is set to default, to get all vertex labels adjacent to the edge
// alias is set to null for it will never be used
return builder.getV(new GetVConfig(getVConfig.getOpt(), LabelConfig.DEFAULT));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public void match_3_test() {
match.explain().trim());
}

// for the sentence `(a:person)-[b:knows*1..3]-(c:person)`:
// b is a path_expand operator, expand base should be `knows` type, getV base should be any
// vertex types adjacent to knows (currently we have not implemented type inference based on
// graph schema, so all vertex types are considered here)
// c is a getV operator which should be `person` type
@Test
public void match_4_test() {
RelNode match =
Expand All @@ -85,8 +90,8 @@ public void match_4_test() {
+ " GraphLogicalPathExpand(expand=[GraphLogicalExpand(tableConfig=[{isAll=false,"
+ " tables=[knows]}], alias=[DEFAULT], fusedFilter=[[=(DEFAULT.weight,"
+ " 1.0E0)]], opt=[OUT])\n"
+ "], getV=[GraphLogicalGetV(tableConfig=[{isAll=false, tables=[person]}],"
+ " alias=[DEFAULT], opt=[END])\n"
+ "], getV=[GraphLogicalGetV(tableConfig=[{isAll=true, tables=[software,"
+ " person]}], alias=[DEFAULT], opt=[END])\n"
+ "], offset=[1], fetch=[2], path_opt=[ARBITRARY], result_opt=[EndV],"
+ " alias=[b])\n"
+ " GraphLogicalSource(tableConfig=[{isAll=false, tables=[person]}],"
Expand Down

0 comments on commit ec218cf

Please sign in to comment.