Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Aug 24, 2021
1 parent 2925292 commit f022492
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
15 changes: 3 additions & 12 deletions src/graph/validator/GetSubgraphValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ Status GetSubgraphValidator::validateImpl() {
NG_RETURN_IF_ERROR(validateOutBound(gsSentence->out()));
NG_RETURN_IF_ERROR(validateBothInOutBound(gsSentence->both()));
NG_RETURN_IF_ERROR(validateYield(gsSentence->yield()));
// set output col & type
if (subgraphCtx_->steps.steps() == 0) {
outputs_.emplace_back(kVertices, Value::Type::VERTEX);
} else {
outputs_.emplace_back(kVertices, Value::Type::VERTEX);
outputs_.emplace_back(kEdges, Value::Type::EDGE);
}
return Status::OK();
}

Expand Down Expand Up @@ -115,21 +108,19 @@ Status GetSubgraphValidator::validateYield(YieldClause* yield) {
for (const auto& col : yield->columns()) {
if (col->expr()->kind() == Expression::Kind::kVertex) {
subgraphCtx_->getVertexProp = true;
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, col->name()), col->name());
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "VERTEX"), col->name());
newCols->addColumn(newCol);
} else if (col->expr()->kind() == Expression::Kind::kEdge) {
if (subgraphCtx_->steps.steps() == 0) {
return Status::SemanticError("Get Subgraph 0 STEPS only support YIELD vertex");
}
subgraphCtx_->getEdgeProp = true;
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, col->name()), col->name());
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "EDGE"), col->name());
newCols->addColumn(newCol);
} else {
return Status::SemanticError("Get Subgraph only support YIELD vertex OR edge");
}
auto type = deduceExprType(col->expr());
NG_RETURN_IF_ERROR(type);
outputs_.emplace_back(col->name(), type.value());
outputs_.emplace_back(col->name(), Value::Type::LIST);
}
subgraphCtx_->yieldExpr = newCols;
subgraphCtx_->colNames = getOutColNames();
Expand Down
14 changes: 7 additions & 7 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:
| _vertices | _edges |
| VERTEX | EDGE |
| [("Tim Duncan")] | <[edge1]> |

Scenario: subgraph as variable with limit
Expand Down Expand Up @@ -65,19 +65,19 @@ 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:
| _vertices | _edges |
| VERTEX | EDGE |
| [("Tim Duncan")] | <[edge1]> |

# TODO: access to the output of get subgraph.
# Currently _vertices is a reserved keyword.
# Currently VERTEX is a reserved keyword.
#
# Scenario: two steps subgraph with limit
# When executing query:
# """
# (root@nebula) [nba]> $a = GET SUBGRAPH WITH PROP 3 STEPS FROM 'Paul George' OUT serve BOTH like | yield COUNT($a._vertices)
# (root@nebula) [nba]> $a = GET SUBGRAPH WITH PROP 3 STEPS FROM 'Paul George' OUT serve BOTH like | yield COUNT($a.VERTEX)
# """
# Then the result should be, in any order, with relax comparison:
# | COUNT($a._vertices) |
# | COUNT($a.VERTEX) |
# | 4 |
Scenario: two steps subgraph with limit
When executing query:
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:
| _vertices | _edges |
| VERTEX | EDGE |
| [("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:
| _vertices | _edges |
| VERTEX | EDGE |
| [("Paul George")] | <[edge1]> |
| [("Russell Westbrook"), ("Pacers"), ("Thunders")] | <[edge2]> |
When executing query:
Expand Down
2 changes: 1 addition & 1 deletion tests/tck/features/subgraph/subgraph.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: Integer Vid subgraph
Then a SemanticError should be raised at runtime: Get Subgraph only support YIELD vertex OR edge
When executing query:
"""
GET SUBGRAPH 0 STEPS WITH PROP FROM hash("Tim Duncan") YIELD edge
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan") YIELD edge
"""
Then a SemanticError should be raised at runtime: Get Subgraph 0 STEPS only support YIELD vertex
When executing query:
Expand Down
3 changes: 2 additions & 1 deletion tests/tck/features/subgraph/subgraph.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
@jmq
Feature: subgraph

Background:
Expand Down Expand Up @@ -30,7 +31,7 @@ Feature: subgraph
Then a SemanticError should be raised at runtime: Get Subgraph only support YIELD vertex OR edge
When executing query:
"""
GET SUBGRAPH 0 STEPS WITH PROP FROM "Tim Duncan" YIELD edge
GET SUBGRAPH WITH PROP 0 STEPS FROM "Tim Duncan" YIELD edge
"""
Then a SemanticError should be raised at runtime: Get Subgraph 0 STEPS only support YIELD vertex
When executing query:
Expand Down

0 comments on commit f022492

Please sign in to comment.