Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Feb 6, 2023
1 parent b3768cd commit a8184cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
11 changes: 6 additions & 5 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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());
}
Expand Down
8 changes: 0 additions & 8 deletions src/parser/MatchPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -237,10 +233,6 @@ class MatchNode final {
return alias_;
}

bool anonymous() const {
return alias_.empty() || alias_.front() == '_';
}

const auto* labels() const {
return labels_.get();
}
Expand Down
10 changes: 5 additions & 5 deletions tests/tck/features/match/PathExpr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -448,29 +448,29 @@ 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"})
WITH v, e, collect(distinct n) AS ns
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.
2 changes: 1 addition & 1 deletion tests/tck/features/match/PathExprRefLocalVariable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit a8184cd

Please sign in to comment.