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 redefined alias in match path #5446

Merged
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
9 changes: 9 additions & 0 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ Status MatchValidator::buildNodeInfo(const MatchPath *path,
anonymous = true;
alias = vctx_->anonVarGen()->getVar();
} else {
// an node alias generated here can be repeated.
// but it cannot be the same with any previously defined ones.
auto iter = aliases.find(alias.c_str());
if (iter != aliases.end()) {
if (iter->second != AliasType::kNode) {
return Status::SemanticError("`%s': alias redefined with a different type",
alias.c_str());
}
}
nodeAliases.emplace(alias, AliasType::kNode);
}
Expression *filter = nullptr;
Expand Down
3 changes: 1 addition & 2 deletions tests/tck/features/match/Path.feature
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ Feature: Matching paths
| count(p) |
| 60 |

@skip #bug to fix: https://github.com/vesoft-inc/nebula/issues/5185
Scenario: conflicting type
When executing query:
"""
Expand All @@ -230,7 +229,7 @@ Feature: Matching paths
where id(v) in [100] and id(v3) in [80]
return count(p), count(p2)
"""
Then a SemanticError should be raised at runtime: `p': defined with conflicting type
Then a SemanticError should be raised at runtime: `p': alias redefined with a different type

Scenario: use of defined vertices
# edges cannot be redefined, tested in Scenario: distinct edges and paths
Expand Down