From a8184cd04347b0737443441c76405b10cbb76556 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Mon, 6 Feb 2023 11:17:35 +0800 Subject: [PATCH] address comment --- src/graph/validator/MatchValidator.cpp | 11 ++++++----- src/parser/MatchPath.h | 8 -------- tests/tck/features/match/PathExpr.feature | 10 +++++----- .../features/match/PathExprRefLocalVariable.feature | 2 +- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/graph/validator/MatchValidator.cpp b/src/graph/validator/MatchValidator.cpp index 2dd421bd5aa..cf6efdb962f 100644 --- a/src/graph/validator/MatchValidator.cpp +++ b/src/graph/validator/MatchValidator.cpp @@ -187,7 +187,7 @@ Status MatchValidator::buildPathExpr(const MatchPath *path, } pathBuild->add(InputPropertyExpression::make(pool, nodeInfos.back().alias)); pathInfo.pathBuild = std::move(pathBuild); - pathInfo.anonymous = false; + pathInfo.anonymous = pathAlias == nullptr; pathInfo.alias = pathAlias == nullptr ? path->toString() : *pathAlias; return Status::OK(); } @@ -1294,16 +1294,17 @@ Status MatchValidator::validatePathInWhere( /*static*/ Status MatchValidator::buildRollUpPathInfo(const MatchPath *path, Path &pathInfo) { for (const auto &node : path->nodes()) { // The inner variable of expression will be replaced by anno variable - if (!node->anonymous()) { - pathInfo.compareVariables.emplace_back(node->alias()); + const auto &nodeAlias = node->alias(); + if (!nodeAlias.empty() && !AnonVarGenerator::isAnnoVar(nodeAlias)) { + pathInfo.compareVariables.emplace_back(nodeAlias); } } for (const auto &edge : path->edges()) { const auto &edgeAlias = edge->alias(); - if (!edge->anonymous()) { + if (!edgeAlias.empty() && !AnonVarGenerator::isAnnoVar(edgeAlias)) { if (edge->range()) { return Status::SemanticError( - "Variable '%s` 's type is list. not support used in multiple patterns " + "Variable '%s` 's type is edge list. not support used in multiple patterns " "simultaneously.", edgeAlias.c_str()); } diff --git a/src/parser/MatchPath.h b/src/parser/MatchPath.h index 2bceb4ff9b9..487ad0dba8b 100644 --- a/src/parser/MatchPath.h +++ b/src/parser/MatchPath.h @@ -115,10 +115,6 @@ class MatchEdge final { return range_.get(); } - bool anonymous() const { - return alias_.empty() || alias_.front() == '_'; - } - std::string toString() const; MatchEdge clone() const { @@ -237,10 +233,6 @@ class MatchNode final { return alias_; } - bool anonymous() const { - return alias_.empty() || alias_.front() == '_'; - } - const auto* labels() const { return labels_.get(); } diff --git a/tests/tck/features/match/PathExpr.feature b/tests/tck/features/match/PathExpr.feature index 6ca399ba541..a2280041533 100644 --- a/tests/tck/features/match/PathExpr.feature +++ b/tests/tck/features/match/PathExpr.feature @@ -448,7 +448,7 @@ Feature: Basic match MATCH (v:player{name: 'Tim Duncan'})-[e:like*2]->(n) RETURN ()-[e:like*2]->(n) """ - Then a SemanticError should be raised at runtime: Variable 'e` 's type is list. not support used in multiple patterns simultaneously. + Then a SemanticError should be raised at runtime: Variable 'e` 's type is edge list. not support used in multiple patterns simultaneously. When executing query: """ MATCH (v:player{name: 'Tim Duncan'})-[e:like*3]->(n), (t:team {name: "Spurs"}) @@ -456,21 +456,21 @@ Feature: Basic match UNWIND [n in ns | ()-[e*3]->(n:player)] AS p RETURN p """ - Then a SemanticError should be raised at runtime: Variable 'e` 's type is list. not support used in multiple patterns simultaneously. + Then a SemanticError should be raised at runtime: Variable 'e` 's type is edge list. not support used in multiple patterns simultaneously. When executing query: """ MATCH (v:player)-[e:like*3]->(n) WHERE (n)-[e*3]->(:player) RETURN v """ - Then a SemanticError should be raised at runtime: Variable 'e` 's type is list. not support used in multiple patterns simultaneously. + Then a SemanticError should be raised at runtime: Variable 'e` 's type is edge list. not support used in multiple patterns simultaneously. When executing query: """ MATCH (v:player)-[e:like*1..3]->(n) WHERE (n)-[e*1..4]->(:player) return v """ - Then a SemanticError should be raised at runtime: Variable 'e` 's type is list. not support used in multiple patterns simultaneously. + Then a SemanticError should be raised at runtime: Variable 'e` 's type is edge list. not support used in multiple patterns simultaneously. When executing query: """ MATCH (v:player)-[e:like*3]->(n) WHERE id(v)=="Tim Duncan" and (n)-[e*3]->(:player) return v """ - Then a SemanticError should be raised at runtime: Variable 'e` 's type is list. not support used in multiple patterns simultaneously. + Then a SemanticError should be raised at runtime: Variable 'e` 's type is edge list. not support used in multiple patterns simultaneously. diff --git a/tests/tck/features/match/PathExprRefLocalVariable.feature b/tests/tck/features/match/PathExprRefLocalVariable.feature index cb490a1bf6b..8483198249d 100644 --- a/tests/tck/features/match/PathExprRefLocalVariable.feature +++ b/tests/tck/features/match/PathExprRefLocalVariable.feature @@ -238,4 +238,4 @@ Feature: Path expression reference local defined variables """ MATCH (v:player{name: 'Tim Duncan'})-[e:like*1..3]->(n), (t:team {name: "Spurs"}) WITH v, e, collect(distinct n) AS ns UNWIND [n in ns | ()-[e*2..4]->(n:player)] AS p RETURN count(p) AS count """ - Then a SemanticError should be raised at runtime: Variable 'e` 's type is list. not support used in multiple patterns simultaneously. + Then a SemanticError should be raised at runtime: Variable 'e` 's type is edge list. not support used in multiple patterns simultaneously.