Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix subgraph step #4776

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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