Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Sep 22, 2021
1 parent fd9a449 commit e0cad66
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/graph/validator/FetchVerticesValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Status FetchVerticesValidator::validateTag(const NameLabelList *nameLabels) {
auto tagID = tagStatus.value();
auto tagSchema = schemaMng->getTagSchema(space_.id, tagID);
if (tagSchema == nullptr) {
return Status::SemanticError("No schema found for `%s'", label->c_str());
return Status::SemanticError("no schema found for `%s'", label->c_str());
}
tagsSchema_.emplace(tagID, tagSchema);
}
Expand All @@ -70,8 +70,7 @@ Status FetchVerticesValidator::validateYield(YieldClause *yield) {
auto pool = qctx_->objPool();
bool noYield = false;
if (yield == nullptr) {
// version 3.0: return Status::SemanticError("No YIELD Clause");
// compatible with previous versions
// TODO: compatible with previous version, this will be deprecated in version 3.0.
auto *yieldColumns = new YieldColumns();
auto *vertex = new YieldColumn(VertexExpression::make(pool), "vertices_");
yieldColumns->addColumn(vertex);
Expand Down Expand Up @@ -124,15 +123,15 @@ Status FetchVerticesValidator::validateYield(YieldClause *yield) {
fetchCtx_->yieldExpr = newCols;

if (exprProps.hasInputVarProperty()) {
return Status::SemanticError("Unsupported input/variable property expression in yield.");
return Status::SemanticError("unsupported input/variable property expression in yield.");
}
if (exprProps.hasSrcDstTagProperty()) {
return Status::SemanticError("Unsupported src/dst property expression in yield.");
return Status::SemanticError("unsupported src/dst property expression in yield.");
}

for (const auto &tag : exprProps.tagNameIds()) {
if (tagsSchema_.find(tag.second) == tagsSchema_.end()) {
return Status::SemanticError("Mismatched tag `%s'", tag.first.c_str());
return Status::SemanticError("mismatched tag `%s'", tag.first.c_str());
}
}
return Status::OK();
Expand Down
6 changes: 6 additions & 0 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ Status MatchValidator::validateReturn(MatchReturn *ret,
}
if (ret->returnItems()->columns()) {
for (auto *column : ret->returnItems()->columns()->columns()) {
if (ExpressionUtils::hasAny(column->expr(),
{Expression::Kind::kVertex, Expression::Kind::kEdge})) {
return Status::SemanticError(
"keyword: vertex | edge is not supported in return clause `%s'",
column->toString().c_str());
}
columns->addColumn(column->clone().release());
}
}
Expand Down
28 changes: 28 additions & 0 deletions src/graph/validator/test/MatchValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,34 @@ TEST_F(MatchValidatorTest, validateAlias) {
EXPECT_EQ(std::string(result.message()),
"SemanticError: Path `p' does not have the type attribute");
}
{
std::string query = "MATCH (v:person) return id(vertex)";
auto result = checkResult(query);
EXPECT_EQ(
std::string(result.message()),
"SemanticError: keyword: vertex | edge is not supported in return clause `id(VERTEX)'");
}
{
std::string query = "MATCH (v:person) return vertex as a";
auto result = checkResult(query);
EXPECT_EQ(
std::string(result.message()),
"SemanticError: keyword: vertex | edge is not supported in return clause `VERTEX AS a'");
}
{
std::string query = "MATCH (v:person)-[e]-(v2) return src(edge)";
auto result = checkResult(query);
EXPECT_EQ(
std::string(result.message()),
"SemanticError: keyword: vertex | edge is not supported in return clause `src(EDGE)'");
}
{
std::string query = "MATCH (v:person)-[e]-(v2) return edge as b";
auto result = checkResult(query);
EXPECT_EQ(
std::string(result.message()),
"SemanticError: keyword: vertex | edge is not supported in return clause `EDGE AS b'");
}
}

} // namespace graph
Expand Down
6 changes: 6 additions & 0 deletions src/graph/validator/test/QueryValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,12 @@ TEST_F(QueryValidatorTest, GoInvalid) {
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()), "SemanticError: Duplicate Column Name : `id'");
}
{
std::string query = "GO FROM id(vertex) OVER * ";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()),
"SemanticError: `id(VERTEX)' is not an evaluable expression.");
}
}

TEST_F(QueryValidatorTest, Limit) {
Expand Down

0 comments on commit e0cad66

Please sign in to comment.