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

Minor optimize for go n steps #4566

Merged
merged 6 commits into from
Sep 1, 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: 3 additions & 4 deletions src/graph/planner/ngql/GoPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,11 @@ SubPlan GoPlanner::oneStepPlan(SubPlan& startVidPlan) {

SubPlan GoPlanner::nStepsPlan(SubPlan& startVidPlan) {
auto qctx = goCtx_->qctx;
auto isSimple = goCtx_->isSimple;
loopStepVar_ = qctx->vctx()->anonVarGen()->getVar();

auto* start = StartNode::make(qctx);
PlanNode* scan = nullptr;
if (isSimple) {
if (!goCtx_->joinInput && goCtx_->limits.empty()) {
auto* gd = GetDstBySrc::make(qctx, start, goCtx_->space.id);
gd->setSrc(goCtx_->from.src);
gd->setEdgeTypes(buildEdgeTypes());
Expand All @@ -461,7 +460,7 @@ SubPlan GoPlanner::nStepsPlan(SubPlan& startVidPlan) {
auto* sampleLimit = buildSampleLimit(scan);

PlanNode* getDst = nullptr;
if (isSimple) {
if (!goCtx_->joinInput && goCtx_->limits.empty()) {
auto* dedup = Dedup::make(qctx, sampleLimit);
dedup->setOutputVar(goCtx_->vidsVar);
dedup->setColNames(goCtx_->colNames);
Expand Down Expand Up @@ -627,7 +626,7 @@ StatusOr<SubPlan> GoPlanner::transform(AstContext* astCtx) {
}

bool GoPlanner::isSimpleCase() {
if (goCtx_->joinDst || goCtx_->filter || !goCtx_->distinct) {
if (goCtx_->joinDst || goCtx_->filter || !goCtx_->distinct || !goCtx_->limits.empty()) {
return false;
}
auto& exprProps = goCtx_->exprProps;
Expand Down
18 changes: 6 additions & 12 deletions src/graph/validator/test/QueryValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ TEST_F(QueryValidatorTest, GoNSteps) {
PK::kLoop,
PK::kStart,
PK::kDedup,
PK::kProject,
PK::kGetNeighbors,
PK::kGetDstBySrc,
PK::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
Expand All @@ -96,8 +95,7 @@ TEST_F(QueryValidatorTest, GoNSteps) {
PK::kLoop,
PK::kStart,
PK::kDedup,
PK::kProject,
PK::kGetNeighbors,
PK::kGetDstBySrc,
PK::kStart,
};
EXPECT_TRUE(checkResult(query, expected));
Expand All @@ -114,8 +112,7 @@ TEST_F(QueryValidatorTest, GoNSteps) {
PK::kLoop,
PK::kStart,
PK::kDedup,
PK::kProject,
PK::kGetNeighbors,
PK::kGetDstBySrc,
PK::kStart,
};
EXPECT_TRUE(checkResult(query, expected));
Expand All @@ -131,8 +128,7 @@ TEST_F(QueryValidatorTest, GoNSteps) {
PK::kLoop,
PK::kStart,
PK::kDedup,
PK::kProject,
PK::kGetNeighbors,
PK::kGetDstBySrc,
PK::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
Expand Down Expand Up @@ -166,8 +162,7 @@ TEST_F(QueryValidatorTest, GoWithPipe) {
PK::kLoop,
PK::kStart,
PK::kDedup,
PK::kProject,
PK::kGetNeighbors,
PK::kGetDstBySrc,
PK::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
Expand Down Expand Up @@ -459,8 +454,7 @@ TEST_F(QueryValidatorTest, GoReversely) {
PK::kLoop,
PK::kStart,
PK::kDedup,
PK::kProject,
PK::kGetNeighbors,
PK::kGetDstBySrc,
PK::kStart,
};
EXPECT_TRUE(checkResult(query, expected));
Expand Down
85 changes: 84 additions & 1 deletion tests/tck/features/go/SimpleCase.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Simple case
| 1 | GetDstBySrc | 0 | |
| 0 | Start | | |

Scenario: go m steps yield distinct dst id
Scenario: go m steps
When profiling query:
"""
GO 3 STEPS FROM "Tony Parker" OVER serve BIDIRECT YIELD DISTINCT id($$) AS dst | YIELD count(*)
Expand All @@ -39,6 +39,89 @@ Feature: Simple case
| 2 | GetDstBySrc | 1 | |
| 1 | Start | | |
| 0 | Start | | |
# The last step degenerates to `GetNeighbors` when yield or filter properties other than `_dst`
When profiling query:
"""
GO 3 STEPS FROM "Tony Parker" OVER serve BIDIRECT YIELD id($$) AS dst | YIELD count(*)
"""
Then the result should be, in any order, with relax comparison:
| count(*) |
| 65 |
And the execution plan should be:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| id | name         | dependencies | profiling data | operator info                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  8 | Aggregate    | 7            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "count(*)"                                                                                      |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Aggregate_8",                                                                          |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_7                                                                               |
|    |              |              |                | groupKeys: []                                                                                       |
|    |              |              |                | groupItems: [                                                                                       |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "expr": "count(*)"                                                                              |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  7 | Project      | 6            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "dst"                                                                                           |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_7",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetNeighbors_6                                                                          |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "*._dst AS dst"                                                                                   |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  6 | GetNeighbors | 5            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__GetNeighbors_6"                                                                        |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __VAR_0                                                                                   |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: false                                                                                        |
|    |              |              |                | limit: -1                                                                                           |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[0]                                                                                      |
|    |              |              |                | edgeTypes: []                                                                                       |
|    |              |              |                | edgeDirection: OUT_EDGE                                                                             |
|    |              |              |                | vertexProps:                                                                                        |
|    |              |              |                | edgeProps: [                                                                                        |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": -6                                                                                      |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": 6,                                                                                      |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | statProps:                                                                                          |
|    |              |              |                | exprs:                                                                                              |
|    |              |              |                | random: false                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  5 | Loop         | 0            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Loop_5"                                                                                |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar:                                                                                           |
|    |              |              |                | condition: ((++($__VAR_1)<=2) AND (($__GetNeighbors_2==__EMPTY__) OR (size($__GetNeighbors_2)!=0))) |
|    |              |              |                | loopBody: 4                                                                                         |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  4 | Dedup        | 3            |                | branch: true, nodeId: 5                                                                             |
|    |              |              |                |                                                                                                     |
|    |              |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__VAR_0",                                                                                |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_3                                                                               |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  3 | Project      | 2            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "_vid"                                                                                          |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_3",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetNeighbors_2                                                                          |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "*._dst AS _vid"                                                                                  |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  2 | GetNeighbors | 1            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__GetNeighbors_2",                                                                       |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __VAR_0                                                                                   |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: false                                                                                        |
|    |              |              |                | limit: -1                                                                                           |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[0]                                                                                      |
|    |              |              |                | edgeTypes: []                                                                                       |
|    |              |              |                | edgeDirection: OUT_EDGE                                                                             |
|    |              |              |                | vertexProps:                                                                                        |
|    |              |              |                | edgeProps: [                                                                                        |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": -6                                                                                      |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": 6,                                                                                      |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | statProps:                                                                                          |
|    |              |              |                | exprs:                                                                                              |
|    |              |              |                | random: false                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  1 | Start        |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Start_1"                                                                               |
|    |              |              |                | }                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  0 | Start        |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__Start_0",                                                                              |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------

| id | name | dependencies | operator info |
| 7 | Aggregate | 6 | |
| 6 | Project | 5 | |
| 5 | GetNeighbors | 4 | |
| 4 | Loop | 0 | {"loopBody": "3"} |
| 3 | Dedup | 2 | |
| 2 | GetDstBySrc | 1 | |
| 1 | Start | | |
| 0 | Start | | |
When profiling query:
"""
GO 3 STEPS FROM "Tony Parker" OVER serve BIDIRECT YIELD $$.player.age AS age | YIELD count(*)
"""
Then the result should be, in any order, with relax comparison:
| count(*) |
| 65 |
And the execution plan should be:
Copy link
Contributor Author

@jievince jievince Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| id | name         | dependencies | profiling data | operator info                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 12 | Aggregate    | 11           |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "count(*)"                                                                                      |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Aggregate_12",                                                                         |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_11                                                                              |
|    |              |              |                | groupKeys: []                                                                                       |
|    |              |              |                | groupItems: [                                                                                       |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "expr": "count(*)"                                                                              |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 11 | Project      | 10           |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "age"                                                                                           |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_11",                                                                           |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __LeftJoin_10                                                                             |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "$__COL_0 AS age"                                                                                 |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 10 | LeftJoin     | 9            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "JOIN_DST_VID",                                                                                 |
|    |              |              |                |     "__COL_0",                                                                                      |
|    |              |              |                |     "DST_VID"                                                                                       |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__LeftJoin_10",                                                                          |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: {                                                                                         |
|    |              |              |                |   "leftVar": {                                                                                      |
|    |              |              |                |     "__Project_7": 0                                                                                |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   "rightVar": {                                                                                     |
|    |              |              |                |     "__Project_9": 0                                                                                |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | hashKeys: [                                                                                         |
|    |              |              |                |   "COLUMN[-1]"                                                                                      |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | probeKeys: [                                                                                        |
|    |              |              |                |   "COLUMN[-1]"                                                                                      |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | kind: LeftJoin                                                                                      |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  9 | Project      | 8            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "__COL_0",                                                                                      |
|    |              |              |                |     "DST_VID"                                                                                       |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_9",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetVertices_8                                                                           |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "$$.player.age AS __COL_0",                                                                       |
|    |              |              |                |   "COLUMN[0] AS DST_VID"                                                                            |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  8 | GetVertices  | 7            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__GetVertices_8"                                                                         |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_7                                                                               |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: true                                                                                         |
|    |              |              |                | limit: 9223372036854775807                                                                          |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[-1]                                                                                     |
|    |              |              |                | props: [                                                                                            |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "age"                                                                                         |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "tagId": 2                                                                                      |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | exprs:                                                                                              |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  7 | Project      | 6            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "JOIN_DST_VID"                                                                                  |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_7",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetNeighbors_6                                                                          |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "*._dst AS JOIN_DST_VID"                                                                          |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  6 | GetNeighbors | 5            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__GetNeighbors_6"                                                                        |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __VAR_0                                                                                   |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: false                                                                                        |
|    |              |              |                | limit: -1                                                                                           |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[0]                                                                                      |
|    |              |              |                | edgeTypes: []                                                                                       |
|    |              |              |                | edgeDirection: OUT_EDGE                                                                             |
|    |              |              |                | vertexProps:                                                                                        |
|    |              |              |                | edgeProps: [                                                                                        |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": -6,                                                                                     |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": 6                                                                                       |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | statProps:                                                                                          |
|    |              |              |                | exprs:                                                                                              |
|    |              |              |                | random: false                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  5 | Loop         | 0            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Loop_5"                                                                                |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar:                                                                                           |
|    |              |              |                | condition: ((++($__VAR_1)<=2) AND (($__GetNeighbors_2==__EMPTY__) OR (size($__GetNeighbors_2)!=0))) |
|    |              |              |                | loopBody: 4                                                                                         |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  4 | Dedup        | 3            |                | branch: true, nodeId: 5                                                                             |
|    |              |              |                |                                                                                                     |
|    |              |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__VAR_0",                                                                                |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_3                                                                               |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  3 | Project      | 2            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "_vid"                                                                                          |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Project_3"                                                                             |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetNeighbors_2                                                                          |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "*._dst AS _vid"                                                                                  |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  2 | GetNeighbors | 1            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__GetNeighbors_2"                                                                        |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __VAR_0                                                                                   |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: false                                                                                        |
|    |              |              |                | limit: -1                                                                                           |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[0]                                                                                      |
|    |              |              |                | edgeTypes: []                                                                                       |
|    |              |              |                | edgeDirection: OUT_EDGE                                                                             |
|    |              |              |                | vertexProps:                                                                                        |
|    |              |              |                | edgeProps: [                                                                                        |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": -6,                                                                                     |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": 6,                                                                                      |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | statProps:                                                                                          |
|    |              |              |                | exprs:                                                                                              |
|    |              |              |                | random: false                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  1 | Start        |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Start_1"                                                                               |
|    |              |              |                | }                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  0 | Start        |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__Start_0",                                                                              |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------

| id | name | dependencies | operator info |
| 11 | Aggregate | 10 | |
| 10 | Project | 9 | |
| 9 | LeftJoin | 8 | |
| 8 | Project | 7 | |
| 7 | GetVertices | 6 | |
| 6 | Project | 5 | |
| 5 | GetNeighbors | 4 | |
| 4 | Loop | 0 | {"loopBody": "3"} |
| 3 | Dedup | 2 | |
| 2 | GetDstBySrc | 1 | |
| 1 | Start | | |
| 0 | Start | | |
When profiling query:
"""
GO 3 STEPS FROM "Tony Parker" OVER * WHERE $$.player.age > 36 YIELD $$.player.age AS age | YIELD count(*)
"""
Then the result should be, in any order, with relax comparison:
| count(*) |
| 10 |
And the execution plan should be:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| id | name         | dependencies | profiling data | operator info                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 13 | Aggregate    | 12           |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "count(*)"                                                                                      |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Aggregate_13"                                                                          |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_12                                                                              |
|    |              |              |                | groupKeys: []                                                                                       |
|    |              |              |                | groupItems: [                                                                                       |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "expr": "count(*)"                                                                              |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 12 | Project      | 11           |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "age"                                                                                           |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_12",                                                                           |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Filter_11                                                                               |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "$__COL_0 AS age"                                                                                 |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 11 | Filter       | 10           |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "JOIN_DST_VID",                                                                                 |
|    |              |              |                |     "__COL_0",                                                                                      |
|    |              |              |                |     "DST_VID"                                                                                       |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Filter_11",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __LeftJoin_10                                                                             |
|    |              |              |                | condition: ($__COL_0>36)                                                                            |
|    |              |              |                | isStable: false                                                                                     |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
| 10 | LeftJoin     | 9            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "JOIN_DST_VID",                                                                                 |
|    |              |              |                |     "__COL_0",                                                                                      |
|    |              |              |                |     "DST_VID"                                                                                       |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__LeftJoin_10"                                                                           |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: {                                                                                         |
|    |              |              |                |   "rightVar": {                                                                                     |
|    |              |              |                |     "__Project_9": 0                                                                                |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   "leftVar": {                                                                                      |
|    |              |              |                |     "__Project_7": 0                                                                                |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | hashKeys: [                                                                                         |
|    |              |              |                |   "COLUMN[-1]"                                                                                      |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | probeKeys: [                                                                                        |
|    |              |              |                |   "COLUMN[-1]"                                                                                      |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | kind: LeftJoin                                                                                      |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  9 | Project      | 8            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "__COL_0",                                                                                      |
|    |              |              |                |     "DST_VID"                                                                                       |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_9",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetVertices_8                                                                           |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "$$.player.age AS __COL_0",                                                                       |
|    |              |              |                |   "COLUMN[0] AS DST_VID"                                                                            |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  8 | GetVertices  | 7            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__GetVertices_8"                                                                         |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_7                                                                               |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: true                                                                                         |
|    |              |              |                | limit: 9223372036854775807                                                                          |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[-1]                                                                                     |
|    |              |              |                | props: [                                                                                            |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "age"                                                                                         |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "tagId": 2                                                                                      |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | exprs:                                                                                              |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  7 | Project      | 6            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "JOIN_DST_VID"                                                                                  |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Project_7"                                                                             |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetNeighbors_6                                                                          |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "*._dst AS JOIN_DST_VID"                                                                          |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  6 | GetNeighbors | 5            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__GetNeighbors_6"                                                                        |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __VAR_0                                                                                   |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: false                                                                                        |
|    |              |              |                | limit: -1                                                                                           |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[0]                                                                                      |
|    |              |              |                | edgeTypes: []                                                                                       |
|    |              |              |                | edgeDirection: OUT_EDGE                                                                             |
|    |              |              |                | vertexProps:                                                                                        |
|    |              |              |                | edgeProps: [                                                                                        |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": 5                                                                                       |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": 6                                                                                       |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": 7                                                                                       |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | statProps:                                                                                          |
|    |              |              |                | exprs:                                                                                              |
|    |              |              |                | random: false                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  5 | Loop         | 0            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Loop_5"                                                                                |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar:                                                                                           |
|    |              |              |                | condition: ((++($__VAR_1)<=2) AND (($__GetNeighbors_2==__EMPTY__) OR (size($__GetNeighbors_2)!=0))) |
|    |              |              |                | loopBody: 4                                                                                         |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  4 | Dedup        | 3            |                | branch: true, nodeId: 5                                                                             |
|    |              |              |                |                                                                                                     |
|    |              |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__VAR_0",                                                                                |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __Project_3                                                                               |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  3 | Project      | 2            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [                                                                                     |
|    |              |              |                |     "_vid"                                                                                          |
|    |              |              |                |   ],                                                                                                |
|    |              |              |                |   "name": "__Project_3",                                                                            |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __GetNeighbors_2                                                                          |
|    |              |              |                | columns: [                                                                                          |
|    |              |              |                |   "*._dst AS _vid"                                                                                  |
|    |              |              |                | ]                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  2 | GetNeighbors | 1            |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__GetNeighbors_2",                                                                       |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
|    |              |              |                | inputVar: __VAR_0                                                                                   |
|    |              |              |                | space: 1                                                                                            |
|    |              |              |                | dedup: false                                                                                        |
|    |              |              |                | limit: -1                                                                                           |
|    |              |              |                | filter:                                                                                             |
|    |              |              |                | orderBy: []                                                                                         |
|    |              |              |                | src: COLUMN[0]                                                                                      |
|    |              |              |                | edgeTypes: []                                                                                       |
|    |              |              |                | edgeDirection: OUT_EDGE                                                                             |
|    |              |              |                | vertexProps:                                                                                        |
|    |              |              |                | edgeProps: [                                                                                        |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": 5,                                                                                      |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ],                                                                                              |
|    |              |              |                |     "type": 6                                                                                       |
|    |              |              |                |   },                                                                                                |
|    |              |              |                |   {                                                                                                 |
|    |              |              |                |     "type": 7,                                                                                      |
|    |              |              |                |     "props": [                                                                                      |
|    |              |              |                |       "_dst"                                                                                        |
|    |              |              |                |     ]                                                                                               |
|    |              |              |                |   }                                                                                                 |
|    |              |              |                | ]                                                                                                   |
|    |              |              |                | statProps:                                                                                          |
|    |              |              |                | exprs:                                                                                              |
|    |              |              |                | random: false                                                                                       |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  1 | Start        |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "name": "__Start_1",                                                                              |
|    |              |              |                |   "type": "DATASET"                                                                                 |
|    |              |              |                | }                                                                                                   |
-----+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------
|  0 | Start        |              |                | outputVar: {                                                                                        |
|    |              |              |                |   "colNames": [],                                                                                   |
|    |              |              |                |   "type": "DATASET",                                                                                |
|    |              |              |                |   "name": "__Start_0"                                                                               |
|    |              |              |                | }                                                                                                   |

| id | name | dependencies | operator info |
| 12 | Aggregate | 11 | |
| 11 | Project | 10 | |
| 10 | Filter | 9 | |
| 9 | LeftJoin | 8 | |
| 8 | Project | 7 | |
| 7 | GetVertices | 6 | |
| 6 | Project | 5 | |
| 5 | GetNeighbors | 4 | |
| 4 | Loop | 0 | {"loopBody": "3"} |
| 3 | Dedup | 2 | |
| 2 | GetDstBySrc | 1 | |
| 1 | Start | | |
| 0 | Start | | |
# Because GetDstBySrc doesn't support limit push down, so degenrate to GetNeighbors when the query contains limit/simple clause
When profiling query:
"""
GO 3 STEPS FROM "Tony Parker" OVER * YIELD DISTINCT id($$) LIMIT [100, 100, 100] | YIELD count(*)
"""
Then the result should be, in any order, with relax comparison:
| count(*) |
| 13 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 11 | Aggregate | 10 | |
| 10 | Dedup | 9 | |
| 9 | Project | 12 | |
| 12 | Limit | 13 | |
| 13 | GetNeighbors | 6 | |
| 6 | Loop | 0 | {"loopBody": "5"} |
| 5 | Dedup | 4 | |
| 4 | Project | 14 | |
| 14 | Limit | 15 | |
| 15 | GetNeighbors | 1 | |
| 1 | Start | | |
| 0 | Start | | |

Scenario: go m to n steps yield distinct dst id
When profiling query:
Expand Down