Skip to content

Commit

Permalink
Merge branch 'master' into fix-latency
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu authored Dec 9, 2021
2 parents cfa4d19 + cd2f4a6 commit 9d183af
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
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) {
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

0 comments on commit 9d183af

Please sign in to comment.