Skip to content

Commit

Permalink
Fix use switch space combine with match (vesoft-inc#2480)
Browse files Browse the repository at this point in the history
Co-authored-by: Yichen Wang <[email protected]>
  • Loading branch information
nebula-bots and Aiee authored Mar 10, 2023
1 parent a6ee894 commit 99d729b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
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

0 comments on commit 99d729b

Please sign in to comment.