Skip to content

Commit

Permalink
fix subgraph step (#4776)
Browse files Browse the repository at this point in the history
* fix subgraph step

* forbid function call in where clause

* fix error
  • Loading branch information
nevermore3 authored Oct 25, 2022
1 parent f053a58 commit efe411d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/graph/executor/algo/SubgraphExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ folly::Future<Status> SubgraphExecutor::handleResponse(RpcResponse&& resps) {
auto listVal = std::make_shared<Value>(std::move(list));
auto iter = std::make_unique<GetNeighborsIter>(listVal);

auto steps = totalSteps_;
if (!subgraph_->oneMoreStep()) {
--steps;
}

if (!process(std::move(iter)) || ++currentStep_ > steps) {
if (!process(std::move(iter)) || ++currentStep_ > totalSteps_) {
filterEdges(0);
return folly::makeFuture<Status>(Status::OK());
} else {
Expand Down
4 changes: 0 additions & 4 deletions src/graph/planner/ngql/SubgraphPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ StatusOr<std::unique_ptr<std::vector<EdgeProp>>> SubgraphPlanner::buildEdgeProps
StatusOr<SubPlan> SubgraphPlanner::nSteps(SubPlan& startVidPlan, const std::string& input) {
auto* qctx = subgraphCtx_->qctx;
const auto& space = subgraphCtx_->space;
const auto& dstTagProps = subgraphCtx_->exprProps.dstTagProps();
const auto& steps = subgraphCtx_->steps;

auto vertexProps = buildVertexProps();
Expand All @@ -89,9 +88,6 @@ StatusOr<SubPlan> SubgraphPlanner::nSteps(SubPlan& startVidPlan, const std::stri
subgraph->setEdgeProps(std::move(edgeProps).value());
subgraph->setInputVar(input);
subgraph->setBiDirectEdgeTypes(subgraphCtx_->biDirectEdgeTypes);
if (subgraphCtx_->getEdgeProp || subgraphCtx_->withProp || !dstTagProps.empty()) {
subgraph->setOneMoreStep();
}

auto* dc = DataCollect::make(qctx, DataCollect::DCKind::kSubgraph);
dc->addDep(subgraph);
Expand Down
8 changes: 8 additions & 0 deletions tests/tck/features/subgraph/subgraph.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ Feature: Integer Vid subgraph
| nodes | relationships |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |
When executing query:
"""
GET SUBGRAPH FROM hash('Tim Duncan') OUT like YIELD vertices as v
"""
Then the result should be, in any order, with relax comparison:
| v |
| [("Tim Duncan")] |
| [("Manu Ginobili"), ("Tony Parker")] |

Scenario: yield Integer Vid two steps
When executing query:
Expand Down
8 changes: 8 additions & 0 deletions tests/tck/features/subgraph/subgraph.feature
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ Feature: subgraph
| nodes | relationships |
| [("Tim Duncan")] | <[edge1]> |
| <[vertex2]> | <[edge2]> |
When executing query:
"""
GET SUBGRAPH FROM 'Tim Duncan' OUT like YIELD vertices as v
"""
Then the result should be, in any order, with relax comparison:
| v |
| [("Tim Duncan")] |
| [("Manu Ginobili"), ("Tony Parker")] |

Scenario: two steps
When executing query:
Expand Down
8 changes: 8 additions & 0 deletions tests/tck/features/subgraph/subgraphWithFilter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Feature: subgraph with fitler
Given a graph with space named "nba"

Scenario: subgraph with edge filter
When executing query:
"""
GET SUBGRAPH FROM 'Tim Duncan' OUT like WHERE like.likeness > 90 YIELD vertices as v
"""
Then the result should be, in any order, with relax comparison:
| v |
| [("Tim Duncan")] |
| [("Manu Ginobili"), ("Tony Parker")] |
When executing query:
"""
GET SUBGRAPH FROM 'Tim Duncan' OUT like WHERE like.likeness > 90 YIELD vertices as v, edges as e
Expand Down

0 comments on commit efe411d

Please sign in to comment.