Skip to content

Commit

Permalink
fix getneighbors edge direction (#5386)
Browse files Browse the repository at this point in the history
Co-authored-by: Yichen Wang <18348405+Aiee@users.noreply.github.com>
  • Loading branch information
jievince and Aiee authored Mar 9, 2023
1 parent 417f9ad commit 8f800e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/graph/executor/test/JoinTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ void JoinTest::testInnerJoin(std::string left, std::string right, DataSet& expec
EXPECT_EQ(result.state(), Result::State::kSuccess) << "LINE: " << line;
}


TEST_F(JoinTest, InnerJoin) {
DataSet expected;
expected.colNames = {"src", "dst", kVid, "tag_prop", "edge_prop", kDst};
Expand Down
4 changes: 4 additions & 0 deletions src/graph/planner/ngql/GoPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ PlanNode* GoPlanner::lastStep(PlanNode* dep, PlanNode* join) {
gn->setVertexProps(buildVertexProps(goCtx_->exprProps.srcTagProps()));
gn->setEdgeProps(buildEdgeProps(false));
gn->setInputVar(goCtx_->vidsVar);
gn->setEdgeDirection(goCtx_->over.direction);

const auto& steps = goCtx_->steps;
auto* sampleLimit = buildSampleLimit(gn, steps.isMToN() ? steps.nSteps() : steps.steps());
Expand Down Expand Up @@ -446,6 +447,7 @@ SubPlan GoPlanner::oneStepPlan(SubPlan& startVidPlan) {
gn->setEdgeProps(buildEdgeProps(false));
gn->setSrc(goCtx_->from.src);
gn->setInputVar(goCtx_->vidsVar);
gn->setEdgeDirection(goCtx_->over.direction);
scan = gn;

auto* sampleLimit = buildSampleLimit(gn, 1 /* one step */);
Expand Down Expand Up @@ -495,6 +497,7 @@ SubPlan GoPlanner::nStepsPlan(SubPlan& startVidPlan) {
gn->setSrc(goCtx_->from.src);
gn->setEdgeProps(buildEdgeProps(true));
gn->setInputVar(goCtx_->vidsVar);
gn->setEdgeDirection(goCtx_->over.direction);
auto* sampleLimit = buildSampleLimit(gn);

getDst = PlannerUtil::extractDstFromGN(qctx, sampleLimit, goCtx_->vidsVar);
Expand Down Expand Up @@ -569,6 +572,7 @@ SubPlan GoPlanner::mToNStepsPlan(SubPlan& startVidPlan) {
gn->setVertexProps(buildVertexProps(goCtx_->exprProps.srcTagProps()));
gn->setEdgeProps(buildEdgeProps(false));
gn->setInputVar(goCtx_->vidsVar);
gn->setEdgeDirection(goCtx_->over.direction);
auto* sampleLimit = buildSampleLimit(gn);

getDst = PlannerUtil::extractDstFromGN(qctx, sampleLimit, goCtx_->vidsVar);
Expand Down
2 changes: 2 additions & 0 deletions src/graph/planner/ngql/PathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ PlanNode* PathPlanner::getNeighbors(PlanNode* dep, bool reverse) {
gn->setEdgeProps(buildEdgeProps(reverse));
gn->setInputVar(gnInputVar);
gn->setDedup();
gn->setEdgeDirection(pathCtx_->over.direction);

PlanNode* result = gn;
if (pathCtx_->filter != nullptr) {
auto* filterExpr = pathCtx_->filter->clone();
Expand Down
30 changes: 26 additions & 4 deletions tests/tck/features/go/GO.feature
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Feature: Go Sentence
| serve._dst |

Scenario: multi edges over all
When executing query:
When profiling query:
"""
GO FROM "Russell Westbrook" OVER * REVERSELY YIELD serve._dst, like._dst
"""
Expand All @@ -348,15 +348,37 @@ Feature: Go Sentence
| EMPTY | "James Harden" |
| EMPTY | "Dejounte Murray" |
| EMPTY | "Paul George" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 2 | Project | 1 | |
| 1 | GetNeighbors | 0 | {"edgeDirection": "IN_EDGE"} |
| 0 | Start | | |
When profiling query:
"""
GO FROM "Russell Westbrook" OVER * BIDIRECT YIELD serve._dst, like._dst
"""
Then the result should be, in any order, with relax comparison:
| serve._dst | like._dst |
| | "Dejounte Murray" |
| | "James Harden" |
| | "Paul George" |
| | "James Harden" |
| | "Paul George" |
| "Thunders" | |
And the execution plan should be:
| id | name | dependencies | operator info |
| 2 | Project | 1 | |
| 1 | GetNeighbors | 0 | {"edgeDirection": "BOTH"} |
| 0 | Start | | |
When executing query:
"""
GO FROM "Russell Westbrook" OVER * REVERSELY YIELD serve._src, like._src
"""
Then the result should be, in any order, with relax comparison:
| serve._src | like._src |
| EMPTY | "Russell Westbrook" |
| EMPTY | "Russell Westbrook" |
| EMPTY | "Russell Westbrook" |
| | "Russell Westbrook" |
| | "Russell Westbrook" |
| | "Russell Westbrook" |
When executing query:
"""
GO FROM "Russell Westbrook" OVER * REVERSELY YIELD like._dst, serve._dst, teammate._dst
Expand Down

0 comments on commit 8f800e4

Please sign in to comment.