Skip to content

Commit

Permalink
change vertex, edge to vertices, edges
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Sep 9, 2021
1 parent 8e46396 commit 6fbb1e9
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 104 deletions.
4 changes: 2 additions & 2 deletions src/graph/planner/ngql/SubgraphPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ StatusOr<SubPlan> SubgraphPlanner::nSteps(SubPlan& startVidPlan, const std::stri
auto* dc = DataCollect::make(qctx, DataCollect::DCKind::kSubgraph);
dc->addDep(loop);
dc->setInputVars({gn->outputVar(), oneMoreStepOutput});
dc->setColNames({"VERTEX", "EDGE"});
dc->setColNames({"VERTICES", "EDGES"});

auto* project = Project::make(qctx, dc, subgraphCtx_->yieldExpr);

Expand Down Expand Up @@ -109,7 +109,7 @@ StatusOr<SubPlan> SubgraphPlanner::zeroStep(SubPlan& startVidPlan, const std::st
auto* func = AggregateExpression::make(pool, "COLLECT", vertexExpr, false);

auto* collect = Aggregate::make(qctx, getVertex, {}, {func});
collect->setColNames({"VERTEX"});
collect->setColNames({"VERTICES"});

SubPlan subPlan;
subPlan.root = collect;
Expand Down
18 changes: 10 additions & 8 deletions src/graph/validator/GetSubgraphValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ Status GetSubgraphValidator::validateYield(YieldClause* yield) {
if (yield == nullptr) {
// version 3.0: return Status::SemanticError("No Yield Clause");
auto* yieldColumns = new YieldColumns();
auto* vertex = new YieldColumn(VertexExpression::make(pool));
auto* vertex = new YieldColumn(LabelExpression::make(pool, "VERTICES"));
yieldColumns->addColumn(vertex);
if (subgraphCtx_->steps.steps() != 0) {
auto* edge = new YieldColumn(EdgeExpression::make(pool));
auto* edge = new YieldColumn(LabelExpression::make(pool, "EDGES"));
yieldColumns->addColumn(edge);
}
yield = pool->add(new YieldClause(yieldColumns));
Expand All @@ -117,19 +117,21 @@ Status GetSubgraphValidator::validateYield(YieldClause* yield) {
YieldColumns* newCols = qctx_->objPool()->add(new YieldColumns());

for (const auto& col : yield->columns()) {
if (col->expr()->kind() == Expression::Kind::kVertex) {
std::string lowerStr = col->expr()->toString();
folly::toLowerAscii(lowerStr);
if (lowerStr == "vertices") {
subgraphCtx_->getVertexProp = true;
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "VERTEX"), col->name());
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "VERTICES"), col->name());
newCols->addColumn(newCol);
} else if (col->expr()->kind() == Expression::Kind::kEdge) {
} else if (lowerStr == "edges") {
if (subgraphCtx_->steps.steps() == 0) {
return Status::SemanticError("Get Subgraph 0 STEPS only support YIELD vertex");
return Status::SemanticError("Get Subgraph 0 STEPS only support YIELD VERTICES");
}
subgraphCtx_->getEdgeProp = true;
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "EDGE"), col->name());
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "EDGES"), col->name());
newCols->addColumn(newCol);
} else {
return Status::SemanticError("Get Subgraph only support YIELD vertex OR edge");
return Status::SemanticError("Get Subgraph only support YIELD VERTICES OR EDGES");
}
outputs_.emplace_back(col->name(), Value::Type::LIST);
}
Expand Down
9 changes: 8 additions & 1 deletion src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -1359,10 +1359,17 @@ yield_column
| KW_EDGE {
$$ = new YieldColumn(EdgeExpression::make(qctx->objPool()));
}
| KW_EDGE KW_AS name_label{
| KW_EDGE KW_AS name_label {
$$ = new YieldColumn(EdgeExpression::make(qctx->objPool()), *$3);
delete $3;
}
| KW_EDGES {
$$ = new YieldColumn(LabelExpression::make(qctx->objPool(), "EDGES"));
}
| KW_EDGES KW_AS name_label {
$$ = new YieldColumn(LabelExpression::make(qctx->objPool(), "EDGES"), *$3);
delete $3;
}
| expression {
$$ = new YieldColumn($1);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/tck/features/bugfix/SubgraphBeforePipe.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: Test get subgraph before pipe
| [:teammate "Tim Duncan"->"Manu Ginobili"@0] |
| [:teammate "Tim Duncan"->"Tony Parker"@0] |
Then the result should be, in any order, with relax comparison:
| VERTEX | EDGE |
| VERTICES | EDGES |
| [("Tim Duncan")] | <[edge1]> |

Scenario: subgraph as variable with limit
Expand Down Expand Up @@ -65,7 +65,7 @@ Feature: Test get subgraph before pipe
| [:teammate "Tim Duncan"->"Manu Ginobili"@0] |
| [:teammate "Tim Duncan"->"Tony Parker"@0] |
Then the result should be, in any order, with relax comparison:
| VERTEX | EDGE |
| VERTICES | EDGES |
| [("Tim Duncan")] | <[edge1]> |

# TODO: access to the output of get subgraph.
Expand Down Expand Up @@ -157,7 +157,7 @@ Feature: Test get subgraph before pipe
| | | [:serve "Tiago Splitter"->"76ers"@0] |
| | | [:serve "Tiago Splitter"->"Hawks"@0] |
Then the result should be, in any order, with relax comparison:
| VERTEX | EDGE |
| VERTICES | EDGES |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |

Expand All @@ -173,7 +173,7 @@ Feature: Test get subgraph before pipe
| [:serve "Paul George"->"Thunders"@0] | [:serve "Russell Westbrook"->"Thunders"@0] |
| [:like "Paul George"->"Russell Westbrook"@0] | [:like "Russell Westbrook"->"James Harden"@0] |
Then the result should be, in any order, with relax comparison:
| VERTEX | EDGE |
| VERTICES | EDGES |
| [("Paul George")] | <[edge1]> |
| [("Russell Westbrook"), ("Pacers"), ("Thunders")] | <[edge2]> |
When executing query:
Expand Down
Loading

0 comments on commit 6fbb1e9

Please sign in to comment.