Skip to content

Commit

Permalink
Merge branch 'master' into refactor_go_planner
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie-Xie authored Mar 13, 2023
2 parents 0ec5e90 + 70b9987 commit 85c8c0a
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 54 deletions.
1 change: 0 additions & 1 deletion src/graph/optimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ nebula_add_library(
rule/GetEdgesTransformRule.cpp
rule/PushLimitDownScanEdgesAppendVerticesRule.cpp
rule/PushTopNDownIndexScanRule.cpp
rule/EliminateAppendVerticesRule.cpp
rule/PushLimitDownScanEdgesRule.cpp
rule/PushFilterDownTraverseRule.cpp
rule/RemoveAppendVerticesBelowJoinRule.cpp
Expand Down
19 changes: 12 additions & 7 deletions src/graph/visitor/PropertyTrackerVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,24 @@ void PropertyTrackerVisitor::visit(EdgePropertyExpression *expr) {
}

void PropertyTrackerVisitor::visit(LabelTagPropertyExpression *expr) {
auto status = qctx_->schemaMng()->toTagID(space_, expr->sym());
if (!status.ok()) {
status_ = std::move(status).status();
return;
}
auto &nodeAlias = static_cast<VariablePropertyExpression *>(expr->label())->prop();
auto &tagName = expr->sym();
auto &propName = expr->prop();

auto ret = qctx_->schemaMng()->toTagID(space_, tagName);
if (!ret.ok()) {
status_ = std::move(ret).status();
return;
// if the we switch space in the query, we need to get the space id from the validation context
// use xxx; match xxx
if (qctx_->vctx()->spaceChosen()) {
space_ = qctx_->vctx()->whichSpace().id;
ret = qctx_->schemaMng()->toTagID(qctx_->vctx()->whichSpace().id, tagName);
if (!ret.ok()) {
status_ = std::move(ret).status();
return;
}
}
}

auto tagId = ret.value();
propsUsed_.insertVertexProp(nodeAlias, tagId, propName);
}
Expand Down
41 changes: 41 additions & 0 deletions tests/tck/features/bugfix/UseSpaceAndMatch.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2023 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
# Fix https://github.com/vesoft-inc/nebula/issues/5263
Feature: Use space combine with Match

Scenario: Use space combine with Match
Given an empty graph
And load "nba" csv data to a new space
When executing query:
"""
CREATE USER IF NOT EXISTS new_user_5263 WITH PASSWORD 'nebula';
"""
Then the execution should be successful
When executing query:
"""
GRANT ROLE ADMIN ON nba TO new_user_5263;
"""
Then the execution should be successful
And wait 3 seconds
When executing query with user "new_user_5263" and password "nebula":
"""
USE nba; MATCH (p)-[e]->(v) WHERE id(p)=="Tony Parker" RETURN v.player.age
"""
Then the result should be, in any order, with relax comparison:
| v.player.age |
| NULL |
| NULL |
| 25 |
| 33 |
| 41 |
| 42 |
| 33 |
| 41 |
| 42 |
When executing query:
"""
DROP USER IF EXISTS new_user_5263;
"""
Then the execution should be successful
Then drop the used space
11 changes: 6 additions & 5 deletions tests/tck/features/optimizer/EliminateAppendVerticesRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Feature: Eliminate AppendVertices rule
| "Tim Duncan" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |

Scenario: eliminate AppendVertices failed with returned path
When profiling query:
Expand Down
23 changes: 12 additions & 11 deletions tests/tck/features/optimizer/PrunePropertiesRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,18 @@ Feature: Prune Properties rule
| scount |
| 270 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 12 | Aggregate | 13 | |
| 13 | HashInnerJoin | 15, 11 | |
| 15 | Project | 4 | |
| 4 | Traverse | 3 | { "vertexProps": "" } |
| 3 | Traverse | 14 | { "vertexProps": "" } |
| 14 | IndexScan | 2 | |
| 2 | Start | | |
| 11 | Project | 9 | |
| 9 | Traverse | 8 | { "vertexProps": "" } |
| 8 | Argument | | |
| id | name | dependencies | operator info |
| 12 | Aggregate | 13 | |
| 13 | HashInnerJoin | 15, 11 | |
| 15 | Project | 5 | |
| 5 | AppendVertices | 4 | |
| 4 | Traverse | 3 | { "vertexProps": "" } |
| 3 | Traverse | 14 | { "vertexProps": "" } |
| 14 | IndexScan | 2 | |
| 2 | Start | | |
| 11 | Project | 9 | |
| 9 | Traverse | 8 | { "vertexProps": "" } |
| 8 | Argument | | |

@distonly
Scenario: return function
Expand Down
55 changes: 30 additions & 25 deletions tests/tck/features/optimizer/PushEFilterDownRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ Feature: Push EFilter down rule
| "Tim Duncan" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player{name: 'Tim Duncan'})<-[e:like{likeness: 95}]-() return v.player.name AS name
Expand All @@ -33,11 +34,12 @@ Feature: Push EFilter down rule
| name |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[e:like|serve{likeness: 95}]-() return v.player.name AS name
Expand All @@ -48,11 +50,12 @@ Feature: Push EFilter down rule
| "Tim Duncan" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(_any(like.likeness,serve.likeness)==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(_any(like.likeness,serve.likeness)==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[e:like*1..2{likeness: 95}]->() return v.player.name AS name
Expand All @@ -64,11 +67,12 @@ Feature: Push EFilter down rule
| "Tim Duncan" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"edge filter": "", "filter": "(like.likeness==95)"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |

Scenario Outline: can't push eFilter down when zero step enabled
When profiling query:
Expand All @@ -81,8 +85,9 @@ Feature: Push EFilter down rule
| "Tim Duncan" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | {"edge filter": "(*.likeness==95)", "filter": ""} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"edge filter": "(*.likeness==95)", "filter": ""} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
11 changes: 6 additions & 5 deletions tests/tck/features/optimizer/PushFilterDownNodeRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ Feature: Push Filter down node rule
| "Tim Duncan" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 5 | Project | 8 | |
| 8 | Traverse | 7 | {"vertex filter": "", "first step filter": "(player.name==\"Tim Duncan\")"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
| id | name | dependencies | operator info |
| 5 | Project | 9 | |
| 9 | AppendVertices | 8 | |
| 8 | Traverse | 7 | {"vertex filter": "", "first step filter": "(player.name==\"Tim Duncan\")"} |
| 7 | IndexScan | 0 | |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[:like]->() WHERE v.player.age == 42 return v.player.name AS name
Expand Down

0 comments on commit 85c8c0a

Please sign in to comment.