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 simple case #5551

Merged
merged 3 commits into from
May 15, 2023
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
19 changes: 13 additions & 6 deletions src/graph/planner/ngql/GoPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,19 @@ StatusOr<SubPlan> GoPlanner::transform(AstContext* astCtx) {
for (auto node : varPtr->writtenBy) {
preRootNode_ = node;
}

auto argNode = Argument::make(qctx, from.runtimeVidName);
argNode->setColNames({from.runtimeVidName});
argNode->setInputVertexRequired(false);
goCtx_->vidsVar = argNode->outputVar();
startNode_ = argNode;
if (goCtx_->isSimple) {
// go from 'xxx' over edge yield distinct edge._dst as id |
// go from $-.id over edge yield distinct edge._dst
// above scenario, the second statement does not need the argument operator
startNode_ = preRootNode_;
goCtx_->vidsVar = varName;
} else {
auto argNode = Argument::make(qctx, from.runtimeVidName);
argNode->setColNames({from.runtimeVidName});
argNode->setInputVertexRequired(false);
goCtx_->vidsVar = argNode->outputVar();
startNode_ = argNode;
}
}
auto& steps = goCtx_->steps;
if (!steps.isMToN() && steps.steps() == 0) {
Expand Down
3 changes: 1 addition & 2 deletions src/graph/validator/GoValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ bool GoValidator::checkDstPropOrVertexExist(const Expression* expr) {
}

bool GoValidator::isSimpleCase() {
if (!goCtx_->limits.empty() || !goCtx_->distinct || goCtx_->filter ||
goCtx_->from.fromType != FromType::kInstantExpr) {
if (!goCtx_->limits.empty() || !goCtx_->distinct || goCtx_->filter != nullptr) {
return false;
}
// Check if the yield cluase uses:
Expand Down
91 changes: 50 additions & 41 deletions tests/tck/features/go/SimpleCase.feature
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,20 @@ Feature: Simple case
| count(*) |
| 28 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 17 | Aggregate | 15 | |
| 15 | Minus | 13,14 | |
| 13 | Project | 16 | |
| 16 | PassThrough | 12 | |
| 12 | Dedup | 11 | |
| 11 | Project | 10 | |
| 10 | HashInnerJoin | 5,9 | |
| 5 | Project | 4 | |
| 4 | Dedup | 3 | |
| 3 | ExpandAll | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |
| 9 | ExpandAll | 8 | |
| 8 | Expand | 7 | |
| 7 | Argument | | |
| 14 | Project | 16 | |
| id | name | dependencies | operator info |
| 14 | Aggregate | 12 | |
| 12 | Minus | 10,11 | |
| 10 | Project | 13 | |
| 13 | PassThrough | 9 | |
| 9 | Project | 8 | |
| 8 | Dedup | 7 | |
| 7 | Expand | 5 | |
| 5 | Project | 4 | |
| 4 | Dedup | 3 | |
| 3 | ExpandAll | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |
| 11 | Project | 13 | |

Scenario: other simple case
When profiling query:
Expand All @@ -393,18 +390,15 @@ Feature: Simple case
| count(*) |
| 0 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 12 | Aggregate | 11 | |
| 11 | Dedup | 10 | |
| 10 | Project | 9 | |
| 9 | HashInnerJoin | 4,8 | |
| 4 | Project | 3 | |
| 3 | Dedup | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |
| 8 | ExpandAll | 7 | |
| 7 | Expand | 6 | |
| 6 | Argument | | |
| id | name | dependencies | operator info |
| 9 | Aggregate | 8 | |
| 8 | Project | 7 | |
| 7 | Dedup | 6 | |
| 6 | Expand | 4 | |
| 4 | Project | 3 | |
| 3 | Dedup | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |
When profiling query:
"""
GO 1 STEP FROM "Tony Parker" OVER * YIELD distinct id($$) as id| GO 3 STEP FROM $-.id OVER * YIELD distinct id($$) | YIELD COUNT(*)
Expand All @@ -413,18 +407,33 @@ Feature: Simple case
| COUNT(*) |
| 22 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 12 | Aggregate | 11 | |
| 11 | Dedup | 10 | |
| 10 | Project | 9 | |
| 9 | HashInnerJoin | 4,8 | |
| 4 | Project | 3 | |
| 3 | Dedup | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |
| 8 | ExpandAll | 7 | |
| 7 | Expand | 6 | |
| 6 | Argument | | |
| id | name | dependencies | operator info |
| 9 | Aggregate | 8 | |
| 8 | Project | 7 | |
| 7 | Dedup | 6 | |
| 6 | Expand | 4 | |
| 4 | Project | 3 | |
| 3 | Dedup | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |
When profiling query:
"""
GO 1 STEP FROM "Tony Parker" OVER * YIELD distinct id($$) as id| GO 2 to 4 STEP FROM $-.id OVER * YIELD distinct id($$) | YIELD COUNT(*)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(*) |
| 26 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 10 | Aggregate | 9 | |
| 9 | Project | 8 | |
| 8 | Dedup | 7 | |
| 7 | ExpandAll | 6 | |
| 6 | Expand | 4 | |
| 4 | Project | 3 | |
| 3 | Dedup | 2 | |
| 2 | Expand | 0 | |
| 0 | Start | | |

Scenario: could not be optimied cases
When profiling query:
Expand Down