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 inconsistent variable in yield and from clause #3430

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
20 changes: 17 additions & 3 deletions src/graph/validator/GoValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,23 @@ Status GoValidator::validateImpl() {
return Status::SemanticError("$- must be referred in FROM before used in WHERE or YIELD");
}

if (!exprProps.varProps().empty() && goCtx_->from.fromType != kVariable) {
return Status::SemanticError(
"A variable must be referred in FROM before used in WHERE or YIELD");
if (!exprProps.varProps().empty()) {
if (goCtx_->from.fromType != kVariable) {
return Status::SemanticError(
"A variable must be referred in FROM before used in WHERE or YIELD");
}
auto varPropsMap = exprProps.varProps();
std::vector<std::string> keys;
for (const auto& [k, v] : varPropsMap) {
keys.emplace_back(k);
}
if (keys.size() > 1) {
return Status::SemanticError("Multiple variable property is not supported in WHERE or YIELD");
}
if (keys.front() != goCtx_->from.userDefinedVarName) {
nevermore3 marked this conversation as resolved.
Show resolved Hide resolved
return Status::SemanticError(
"A variable must be referred in FROM before used in WHERE or YIELD");
}
}

if ((!exprProps.inputProps().empty() && !exprProps.varProps().empty()) ||
Expand Down
28 changes: 28 additions & 0 deletions tests/tck/features/go/GO.feature
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,34 @@ Feature: Go Sentence
RETURN $B IF $A IS NOT NULL
"""
Then a SemanticError should be raised at runtime: `$a.id', not exist variable `a'
When executing query:
"""
$A = GO FROM 'Tim Duncan' OVER like YIELD like._dst AS dst;
$B = GO FROM $A.dst OVER like YIELD like._dst AS dst;
GO FROM $A.dst over like YIELD like._dst AS dst, $B.dst
"""
Then a SemanticError should be raised at runtime: A variable must be referred in FROM before used in WHERE or YIELD
When executing query:
"""
$A = GO FROM 'Tim Duncan' OVER like YIELD like._dst AS dst;
$B = GO FROM $A.dst OVER like YIELD like._dst AS dst;
GO FROM $A.dst over like WHERE $B.dst > "A" YIELD like._dst AS dst
"""
Then a SemanticError should be raised at runtime: A variable must be referred in FROM before used in WHERE or YIELD
When executing query:
"""
$A = GO FROM 'Tim Duncan' OVER like YIELD like._dst AS dst;
$B = GO FROM $A.dst OVER like YIELD like._dst AS dst;
GO FROM $A.dst over like YIELD like._dst AS dst, $B.dst, $A.dst
"""
Then a SemanticError should be raised at runtime: Multiple variable property is not supported in WHERE or YIELD
When executing query:
"""
$A = GO FROM 'Tim Duncan' OVER like YIELD like._dst AS dst;
$B = GO FROM $A.dst OVER like YIELD like._dst AS dst;
GO FROM $A.dst over like WHERE $A.dst > "A" and $B.dst > "B" YIELD like._dst
"""
Then a SemanticError should be raised at runtime: Multiple variable property is not supported in WHERE or YIELD
When executing query:
"""
RETURN $rA IF $rA IS NOT NULL;
Expand Down