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 mistake push down limit with skip. #5241

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 7 additions & 9 deletions src/graph/executor/algo/BFSShortestPathExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,13 @@ folly::Future<Status> BFSShortestPathExecutor::conjunctPath() {
}
}

return folly::collect(futures)
.via(runner())
.thenValue([this](auto&& resps) {
memory::MemoryCheckGuard guard;
for (auto& resp : resps) {
currentDs_.append(std::move(resp));
}
return Status::OK();
});
return folly::collect(futures).via(runner()).thenValue([this](auto&& resps) {
memory::MemoryCheckGuard guard;
for (auto& resp : resps) {
currentDs_.append(std::move(resp));
}
return Status::OK();
});
}

DataSet BFSShortestPathExecutor::doConjunct(const std::vector<Value>& meetVids,
Expand Down
24 changes: 11 additions & 13 deletions src/graph/executor/algo/ProduceAllPathsExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,17 @@ folly::Future<Status> ProduceAllPathsExecutor::conjunctPath() {
}
}

return folly::collect(futures)
.via(runner())
.thenValue([this](auto&& resps) {
memory::MemoryCheckGuard guard;
for (auto& resp : resps) {
currentDs_.append(std::move(resp));
}
preLeftPaths_.swap(leftPaths_);
preRightPaths_.swap(rightPaths_);
leftPaths_.clear();
rightPaths_.clear();
return Status::OK();
});
return folly::collect(futures).via(runner()).thenValue([this](auto&& resps) {
memory::MemoryCheckGuard guard;
for (auto& resp : resps) {
currentDs_.append(std::move(resp));
}
preLeftPaths_.swap(leftPaths_);
preRightPaths_.swap(rightPaths_);
leftPaths_.clear();
rightPaths_.clear();
return Status::OK();
});
}

void ProduceAllPathsExecutor::setNextStepVid(Interims& paths, const string& var) {
Expand Down
7 changes: 2 additions & 5 deletions src/graph/executor/maintain/EdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ folly::Future<Status> ShowEdgesExecutor::execute() {
SCOPED_TIMER(&execTime_);

auto spaceId = qctx()->rctx()->session()->space().id;
return qctx()
->getMetaClient()
->listEdgeSchemas(spaceId)
.via(runner())
.thenValue([this, spaceId](StatusOr<std::vector<meta::cpp2::EdgeItem>> resp) {
return qctx()->getMetaClient()->listEdgeSchemas(spaceId).via(runner()).thenValue(
[this, spaceId](StatusOr<std::vector<meta::cpp2::EdgeItem>> resp) {
memory::MemoryCheckGuard guard;
if (!resp.ok()) {
LOG(WARNING) << "SpaceId: " << spaceId << ", Show edges failed: " << resp.status();
Expand Down
14 changes: 4 additions & 10 deletions src/graph/executor/maintain/EdgeIndexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,8 @@ folly::Future<Status> ShowEdgeIndexesExecutor::execute() {
auto *iNode = asNode<ShowEdgeIndexes>(node());
const auto &bySchema = iNode->name();
auto spaceId = qctx()->rctx()->session()->space().id;
return qctx()
->getMetaClient()
->listEdgeIndexes(spaceId)
.via(runner())
.thenValue([this, spaceId, bySchema](StatusOr<std::vector<meta::cpp2::IndexItem>> resp) {
return qctx()->getMetaClient()->listEdgeIndexes(spaceId).via(runner()).thenValue(
[this, spaceId, bySchema](StatusOr<std::vector<meta::cpp2::IndexItem>> resp) {
memory::MemoryCheckGuard guard;
if (!resp.ok()) {
LOG(WARNING) << "SpaceId: " << spaceId << ", Show edge indexes failed" << resp.status();
Expand Down Expand Up @@ -174,11 +171,8 @@ folly::Future<Status> ShowEdgeIndexStatusExecutor::execute() {
SCOPED_TIMER(&execTime_);

auto spaceId = qctx()->rctx()->session()->space().id;
return qctx()
->getMetaClient()
->listEdgeIndexStatus(spaceId)
.via(runner())
.thenValue([this, spaceId](StatusOr<std::vector<meta::cpp2::IndexStatus>> resp) {
return qctx()->getMetaClient()->listEdgeIndexStatus(spaceId).via(runner()).thenValue(
[this, spaceId](StatusOr<std::vector<meta::cpp2::IndexStatus>> resp) {
memory::MemoryCheckGuard guard;
if (!resp.ok()) {
LOG(WARNING) << "SpaceId: " << spaceId << ", Show edge index status failed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformAppendVerticesLimitRule::tra

newLimitGroupNode->dependsOn(newAppendVerticesGroup);

auto *newScanEdges = GetEdgesTransformUtils::traverseToScanEdges(traverse, limit->count(qctx));
auto *newScanEdges =
GetEdgesTransformUtils::traverseToScanEdges(traverse, limit->offset() + limit->count(qctx));
if (newScanEdges == nullptr) {
return TransformResult::noTransform();
}
Expand Down
3 changes: 2 additions & 1 deletion src/graph/optimizer/rule/GetEdgesTransformRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformRule::transform(
newProjectGroupNode->dependsOn(newLimitGroup);
newProject->setInputVar(newLimit->outputVar());

auto *newScanEdges = GetEdgesTransformUtils::traverseToScanEdges(traverse, limit->count(qctx));
auto *newScanEdges =
GetEdgesTransformUtils::traverseToScanEdges(traverse, limit->offset() + limit->count(qctx));
if (newScanEdges == nullptr) {
return TransformResult::noTransform();
}
Expand Down
123 changes: 123 additions & 0 deletions tests/tck/features/match/Scan.feature
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,67 @@ Feature: Match seek by scan
| Name |
| "Mary" |

Scenario: query vertices by scan with skip limit
When executing query:
"""
MATCH (v)
RETURN v.person.name AS name
SKIP 10 LIMIT 4
"""
Then the result should be, in any order:
| name |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
Shylock-Hg marked this conversation as resolved.
Show resolved Hide resolved
When executing query:
"""
MATCH (v)
RETURN v.person.name AS name
SKIP 10 LIMIT 5
"""
Then the result should be, in any order:
| name |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
When executing query:
"""
MATCH (v)
RETURN v.person.name AS name
SKIP 10 LIMIT 7
"""
Then the result should be, in any order:
| name |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
When executing query:
"""
MATCH (v)
RETURN v.person.name AS name
SKIP 10 LIMIT 11
"""
Then the result should be, in any order:
| name |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |

Scenario: query vertices by scan failed
When executing query:
"""
Expand Down Expand Up @@ -168,3 +229,65 @@ Feature: Match seek by scan
LIMIT 3
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.

# #5223
Scenario: query edge by scan with skip limit
When executing query:
"""
MATCH ()-[e]->()
RETURN type(e) AS Type
SKIP 10 LIMIT 4
"""
Then the result should be, in any order:
| Type |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
When executing query:
"""
MATCH ()-[e]->()
RETURN type(e) AS Type
SKIP 10 LIMIT 5
"""
Then the result should be, in any order:
| Type |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
When executing query:
"""
MATCH ()-[e]->()
RETURN type(e) AS Type
SKIP 10 LIMIT 7
"""
Then the result should be, in any order:
| Type |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
When executing query:
"""
MATCH ()-[e]->()
RETURN type(e) AS Type
SKIP 10 LIMIT 11
"""
Then the result should be, in any order:
| Type |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |
| /[\w_]+/ |