From b92f5d9a47b568050811ae1681bc5af5c78d5039 Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Wed, 8 Mar 2023 19:46:37 +0800 Subject: [PATCH 1/4] Fix use switch space combine with match --- src/graph/visitor/PropertyTrackerVisitor.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/graph/visitor/PropertyTrackerVisitor.cpp b/src/graph/visitor/PropertyTrackerVisitor.cpp index 451f9ded7b7..ede1c764fea 100644 --- a/src/graph/visitor/PropertyTrackerVisitor.cpp +++ b/src/graph/visitor/PropertyTrackerVisitor.cpp @@ -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(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); } From 15ef3fe75144608af0533c5779d17f26c40cae02 Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Wed, 8 Mar 2023 20:06:53 +0800 Subject: [PATCH 2/4] Add test --- .../features/bugfix/UseSpaceAndMatch.feature | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/tck/features/bugfix/UseSpaceAndMatch.feature diff --git a/tests/tck/features/bugfix/UseSpaceAndMatch.feature b/tests/tck/features/bugfix/UseSpaceAndMatch.feature new file mode 100644 index 00000000000..2a070bf13eb --- /dev/null +++ b/tests/tck/features/bugfix/UseSpaceAndMatch.feature @@ -0,0 +1,40 @@ +# Copyright (c) 2022 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 + + Background: + Given a graph with space named "nba" + + # The edge range will use same hard code innner variable name for list comprehension + # It's not stable to reproduce, so run multiple times + Scenario: Use space combine with Match + When executing query: + """ + CREATE USER IF NOT EXISTS new_user WITH PASSWORD 'nebula'; + """ + And wait 6 seconds + Then the execution should be successful + When executing query: + """ + GRANT ROLE ADMIN ON nba TO new_user; + """ + Then the execution should be successful + And wait 3 seconds + When switch to new session with user "new_user" and password "nebula" + And executing query: + """ + 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 | From 7011edd27fcf4ecb6a3f29be9baab173df237d67 Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Wed, 8 Mar 2023 20:11:40 +0800 Subject: [PATCH 3/4] format --- tests/tck/features/bugfix/UseSpaceAndMatch.feature | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/tck/features/bugfix/UseSpaceAndMatch.feature b/tests/tck/features/bugfix/UseSpaceAndMatch.feature index 2a070bf13eb..458664349aa 100644 --- a/tests/tck/features/bugfix/UseSpaceAndMatch.feature +++ b/tests/tck/features/bugfix/UseSpaceAndMatch.feature @@ -1,4 +1,4 @@ -# Copyright (c) 2022 vesoft inc. All rights reserved. +# 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 @@ -7,8 +7,6 @@ Feature: Use space combine with Match Background: Given a graph with space named "nba" - # The edge range will use same hard code innner variable name for list comprehension - # It's not stable to reproduce, so run multiple times Scenario: Use space combine with Match When executing query: """ From 598403dfe72abd82c673d1598079bf51739456e7 Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Thu, 9 Mar 2023 01:03:55 +0800 Subject: [PATCH 4/4] tune tests --- .../features/bugfix/UseSpaceAndMatch.feature | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/tck/features/bugfix/UseSpaceAndMatch.feature b/tests/tck/features/bugfix/UseSpaceAndMatch.feature index 458664349aa..c9883160f09 100644 --- a/tests/tck/features/bugfix/UseSpaceAndMatch.feature +++ b/tests/tck/features/bugfix/UseSpaceAndMatch.feature @@ -4,24 +4,21 @@ # Fix https://github.com/vesoft-inc/nebula/issues/5263 Feature: Use space combine with Match - Background: - Given a graph with space named "nba" - 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 WITH PASSWORD 'nebula'; + CREATE USER IF NOT EXISTS new_user_5263 WITH PASSWORD 'nebula'; """ - And wait 6 seconds Then the execution should be successful When executing query: """ - GRANT ROLE ADMIN ON nba TO new_user; + GRANT ROLE ADMIN ON nba TO new_user_5263; """ Then the execution should be successful And wait 3 seconds - When switch to new session with user "new_user" and password "nebula" - And executing query: + 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 """ @@ -36,3 +33,9 @@ Feature: Use space combine with Match | 33 | | 41 | | 42 | + When executing query: + """ + DROP USER IF EXISTS new_user_5263; + """ + Then the execution should be successful + Then drop the used space