Skip to content

Commit

Permalink
compatible with column names
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Sep 9, 2021
1 parent 9d1e4c7 commit de23299
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/graph/planner/ngql/SubgraphPlanner.cpp
Original file line number Diff line number Diff line change
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({"VERTICES"});
collect->setColNames(std::move(subgraphCtx_->colNames));

SubPlan subPlan;
subPlan.root = collect;
Expand Down
8 changes: 4 additions & 4 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(LabelExpression::make(pool, "VERTICES"));
auto* vertex = new YieldColumn(LabelExpression::make(pool, "_vertices"));
yieldColumns->addColumn(vertex);
if (subgraphCtx_->steps.steps() != 0) {
auto* edge = new YieldColumn(LabelExpression::make(pool, "EDGES"));
auto* edge = new YieldColumn(LabelExpression::make(pool, "_edges"));
yieldColumns->addColumn(edge);
}
yield = pool->add(new YieldClause(yieldColumns));
Expand All @@ -119,11 +119,11 @@ Status GetSubgraphValidator::validateYield(YieldClause* yield) {
for (const auto& col : yield->columns()) {
std::string lowerStr = col->expr()->toString();
folly::toLowerAscii(lowerStr);
if (lowerStr == "vertices") {
if (lowerStr == "vertices" || lowerStr == "_vertices") {
subgraphCtx_->getVertexProp = true;
auto* newCol = new YieldColumn(InputPropertyExpression::make(pool, "VERTICES"), col->name());
newCols->addColumn(newCol);
} else if (lowerStr == "edges") {
} else if (lowerStr == "edges" || lowerStr == "_edges") {
if (subgraphCtx_->steps.steps() == 0) {
return Status::SemanticError("Get Subgraph 0 STEPS only support YIELD VERTICES");
}
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 @@ -11,7 +11,7 @@ Feature: Test get subgraph before pipe
Scenario: subgraph with limit
When executing query:
"""
GET SUBGRAPH WITH PROP FROM 'Tim Duncan' | LIMIT 1
GET SUBGRAPH WITH PROP FROM 'Tim Duncan' YIELD VERTICES, EDGES | LIMIT 1
"""
Then define some list variables:
| edge1 |
Expand Down Expand Up @@ -41,7 +41,7 @@ Feature: Test get subgraph before pipe
Scenario: subgraph as variable with limit
When executing query:
"""
$a = GET SUBGRAPH WITH PROP FROM 'Tim Duncan' | LIMIT 1
$a = GET SUBGRAPH WITH PROP FROM 'Tim Duncan' YIELD VERTICES, EDGES| LIMIT 1
"""
Then define some list variables:
| edge1 |
Expand Down Expand Up @@ -82,7 +82,7 @@ Feature: Test get subgraph before pipe
Scenario: two steps subgraph with limit
When executing query:
"""
GET SUBGRAPH WITH PROP 2 STEPS FROM 'Tim Duncan' | LIMIT 2
GET SUBGRAPH WITH PROP 2 STEPS FROM 'Tim Duncan' YIELD VERTICES, EDGES | LIMIT 2
"""
Then define some list variables:
| edge1 | vertex2 | edge2 |
Expand Down Expand Up @@ -164,7 +164,7 @@ Feature: Test get subgraph before pipe
Scenario: three steps subgraph with property + direction + limit
When executing query:
"""
GET SUBGRAPH WITH PROP 3 STEPS FROM 'Paul George' OUT serve BOTH like | LIMIT 2
GET SUBGRAPH WITH PROP 3 STEPS FROM 'Paul George' OUT serve BOTH like YIELD VERTICES, EDGES| LIMIT 2
"""
Then define some list variables:
| edge1 | edge2 |
Expand Down
56 changes: 28 additions & 28 deletions tests/tck/features/subgraph/subgraph.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,49 +62,49 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid zero step
When executing query:
"""
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan")
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan") YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
| [("Tim Duncan")] |
When executing query:
"""
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan"), hash("Spurs")
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan"), hash("Spurs") YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
| [("Tim Duncan"), ("Spurs")] |
When executing query:
"""
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan"), hash("Tony Parker"), hash("Spurs")
GET SUBGRAPH WITH PROP 0 STEPS FROM hash("Tim Duncan"), hash("Tony Parker"), hash("Spurs") YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
| [("Tim Duncan"), ("Spurs"), ("Tony Parker")] |
When executing query:
"""
GO FROM hash('Tim Duncan') over serve YIELD serve._dst AS id | GET SUBGRAPH WITH PROP 0 STEPS FROM $-.id
GO FROM hash('Tim Duncan') over serve YIELD serve._dst AS id | GET SUBGRAPH WITH PROP 0 STEPS FROM $-.id YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
| [("Spurs")] |
When executing query:
"""
GO FROM hash('Tim Duncan') over like YIELD like._dst AS id | GET SUBGRAPH WITH PROP 0 STEPS FROM $-.id
GO FROM hash('Tim Duncan') over like YIELD like._dst AS id | GET SUBGRAPH WITH PROP 0 STEPS FROM $-.id YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
| [("Manu Ginobili"), ("Tony Parker")] |
When executing query:
"""
$a = GO FROM hash('Tim Duncan') over serve YIELD serve._dst AS id; GET SUBGRAPH WITH PROP 0 STEPS FROM $a.id
$a = GO FROM hash('Tim Duncan') over serve YIELD serve._dst AS id; GET SUBGRAPH WITH PROP 0 STEPS FROM $a.id YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
| [("Spurs")] |
When executing query:
"""
$a = GO FROM hash('Tim Duncan') over like YIELD like._dst AS id; GET SUBGRAPH WITH PROP 0 STEPS FROM $a.id
$a = GO FROM hash('Tim Duncan') over like YIELD like._dst AS id; GET SUBGRAPH WITH PROP 0 STEPS FROM $a.id YIELD VERTICES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES |
Expand Down Expand Up @@ -143,7 +143,7 @@ Feature: Integer Vid subgraph
| | | [:like "Danny Green"->"Marco Belinelli"@0] |
| | | [:serve "Danny Green"->"Spurs"@0] |
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| _vertices | _edges |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |

Expand Down Expand Up @@ -225,7 +225,7 @@ Feature: Integer Vid subgraph
| | | [:serve "Tiago Splitter"->"76ers"@0] | | |
| | | [:serve "Tiago Splitter"->"Hawks"@0] | | |
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| _vertices | _edges |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |
| <[vertex3]> | <[edge3]> |
Expand Down Expand Up @@ -255,7 +255,7 @@ Feature: Integer Vid subgraph
| | | [:like "Marco Belinelli"->"Tony Parker"@0] | |
| | | [:like "Tim Duncan"->"Tony Parker"@0] | |
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| _vertices | _edges |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |
| <[vertex3]> | [] |
Expand Down Expand Up @@ -321,15 +321,15 @@ Feature: Integer Vid subgraph
| | | [:like "Marco Belinelli"->"Tony Parker"@0] | | |
| | | [:like "Tim Duncan"->"Tony Parker"@0] | | |
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| _vertices | _edges |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |
| <[vertex3]> | <[edge3]> |

Scenario: Integer Vid two steps in and out edge
When executing query:
"""
GET SUBGRAPH WITH PROP 2 STEPS FROM hash('Tim Duncan'), hash('James Harden') IN teammate OUT serve
GET SUBGRAPH WITH PROP 2 STEPS FROM hash('Tim Duncan'), hash('James Harden') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then define some list variables:
| vertex1 | edge1 | vertex2 | edge2 | vertex3 |
Expand All @@ -349,7 +349,7 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid three steps
When executing query:
"""
GET SUBGRAPH WITH PROP 3 STEPS FROM hash('Paul George') OUT serve BOTH like
GET SUBGRAPH WITH PROP 3 STEPS FROM hash('Paul George') OUT serve BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | edge2 | edge3 | vertex4 | edge4 |
Expand Down Expand Up @@ -384,7 +384,7 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid bidirect edge
When executing query:
"""
GET SUBGRAPH WITH PROP FROM hash('Tony Parker') BOTH like
GET SUBGRAPH WITH PROP FROM hash('Tony Parker') BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 |
Expand All @@ -404,7 +404,7 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid pipe
When executing query:
"""
GO FROM hash('Tim Duncan') over serve YIELD serve._src AS id | GET SUBGRAPH WITH PROP FROM $-.id
GO FROM hash('Tim Duncan') over serve YIELD serve._src AS id | GET SUBGRAPH WITH PROP FROM $-.id YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 |
Expand Down Expand Up @@ -442,7 +442,7 @@ Feature: Integer Vid subgraph
When executing query:
"""
$a = GO FROM hash('Tim Duncan') over serve YIELD serve._src AS id;
GET SUBGRAPH WITH PROP FROM $a.id
GET SUBGRAPH WITH PROP FROM $a.id YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 |
Expand Down Expand Up @@ -479,22 +479,22 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid many steps
When executing query:
"""
GET SUBGRAPH WITH PROP 4 STEPS FROM hash('Yao Ming') IN teammate OUT serve
GET SUBGRAPH WITH PROP 4 STEPS FROM hash('Yao Ming') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| [("Yao Ming")] | [[:serve "Yao Ming"->"Rockets"@0]] |
| [("Rockets")] | [] |
When executing query:
"""
GET SUBGRAPH WITH PROP 4 STEPS FROM hash('NOBODY') IN teammate OUT serve
GET SUBGRAPH WITH PROP 4 STEPS FROM hash('NOBODY') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| [("NOBODY")] | [] |
When executing query:
"""
GET SUBGRAPH WITH PROP 4 steps from hash('Yao Ming') IN teammate OUT serve BOTH like
GET SUBGRAPH WITH PROP 4 steps from hash('Yao Ming') IN teammate OUT serve BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 | vertex3 | edge3 | vertex4 | edge4 | vertex5 | edge5 |
Expand Down Expand Up @@ -580,7 +580,7 @@ Feature: Integer Vid subgraph
| <[vertex5]> | <[edge5]> |
When executing query:
"""
GET SUBGRAPH WITH PROP 5 steps from hash('Tony Parker') IN teammate OUT serve BOTH like
GET SUBGRAPH WITH PROP 5 steps from hash('Tony Parker') IN teammate OUT serve BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 | vertex3 | edge3 | vertex4 | edge4 | vertex5 | edge5 | vertex6 | edge6 |
Expand Down Expand Up @@ -649,7 +649,7 @@ Feature: Integer Vid subgraph
| <[vertex6]> | <[edge6]> |
When executing query:
"""
GET SUBGRAPH WITH PROP 4 steps from hash('Tim Duncan') BOTH like
GET SUBGRAPH WITH PROP 4 steps from hash('Tim Duncan') BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 | vertex3 | edge3 | vertex4 | edge4 | vertex5 |
Expand Down Expand Up @@ -687,15 +687,15 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid over end
When executing query:
"""
GET SUBGRAPH WITH PROP 10000000000000 STEPS FROM hash('Yao Ming') IN teammate OUT serve
GET SUBGRAPH WITH PROP 10000000000000 STEPS FROM hash('Yao Ming') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| [("Yao Ming")] | [[:serve "Yao Ming"->"Rockets"@0]] |
| [("Rockets")] | [] |
When executing query:
"""
GET SUBGRAPH 10000000000000 STEPS FROM hash('Yao Ming') IN teammate OUT serve
GET SUBGRAPH 10000000000000 STEPS FROM hash('Yao Ming') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
Expand All @@ -705,22 +705,22 @@ Feature: Integer Vid subgraph
Scenario: Integer Vid many steps without prop
When executing query:
"""
GET SUBGRAPH 4 STEPS FROM hash('Yao Ming') IN teammate OUT serve
GET SUBGRAPH 4 STEPS FROM hash('Yao Ming') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| [("Yao Ming")] | [[:serve "Yao Ming"->"Rockets"@0]] |
| [("Rockets")] | [] |
When executing query:
"""
GET SUBGRAPH 4 STEPS FROM hash('NOBODY') IN teammate OUT serve
GET SUBGRAPH 4 STEPS FROM hash('NOBODY') IN teammate OUT serve YIELD VERTICES, EDGES
"""
Then the result should be, in any order, with relax comparison:
| VERTICES | EDGES |
| [("NOBODY")] | [] |
When executing query:
"""
GET SUBGRAPH 4 steps from hash('Yao Ming') IN teammate OUT serve BOTH like
GET SUBGRAPH 4 steps from hash('Yao Ming') IN teammate OUT serve BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 | vertex3 | edge3 | vertex4 | edge4 | vertex5 | edge5 |
Expand Down Expand Up @@ -806,7 +806,7 @@ Feature: Integer Vid subgraph
| <[vertex5]> | <[edge5]> |
When executing query:
"""
GET SUBGRAPH 5 steps from hash('Tony Parker') IN teammate OUT serve BOTH like
GET SUBGRAPH 5 steps from hash('Tony Parker') IN teammate OUT serve BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 | vertex3 | edge3 | vertex4 | edge4 | vertex5 | edge5 | vertex6 | edge6 |
Expand Down Expand Up @@ -875,7 +875,7 @@ Feature: Integer Vid subgraph
| <[vertex6]> | <[edge6]> |
When executing query:
"""
GET SUBGRAPH 4 steps from hash('Tim Duncan') BOTH like
GET SUBGRAPH 4 steps from hash('Tim Duncan') BOTH like YIELD VERTICES, EDGES
"""
Then define some list variables:
| edge1 | vertex2 | edge2 | vertex3 | edge3 | vertex4 | edge4 | vertex5 |
Expand Down
Loading

0 comments on commit de23299

Please sign in to comment.