Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use switch space combine with match #5390

Merged
merged 6 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 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