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 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
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_]+/ |