diff --git a/src/graph/validator/LookupValidator.cpp b/src/graph/validator/LookupValidator.cpp index de1672b6f0c..d5099f83f18 100644 --- a/src/graph/validator/LookupValidator.cpp +++ b/src/graph/validator/LookupValidator.cpp @@ -106,7 +106,7 @@ Status LookupValidator::validateYieldEdge() { auto yieldExpr = lookupCtx_->yieldExpr; for (auto col : yield->columns()) { if (ExpressionUtils::hasAny(col->expr(), - {Expression::Kind::kPathBuild, Expression::Kind::kVertex})) { + {Expression::Kind::kAggregate, Expression::Kind::kVertex})) { return Status::SemanticError("illegal yield clauses `%s'", col->toString().c_str()); } if (ExpressionUtils::hasAny(col->expr(), {Expression::Kind::kEdge})) { @@ -136,7 +136,7 @@ Status LookupValidator::validateYieldTag() { auto yieldExpr = lookupCtx_->yieldExpr; for (auto col : yield->columns()) { if (ExpressionUtils::hasAny(col->expr(), - {Expression::Kind::kPathBuild, Expression::Kind::kEdge})) { + {Expression::Kind::kAggregate, Expression::Kind::kEdge})) { return Status::SemanticError("illegal yield clauses `%s'", col->toString().c_str()); } if (ExpressionUtils::hasAny(col->expr(), {Expression::Kind::kVertex})) { diff --git a/src/graph/validator/test/LookupValidatorTest.cpp b/src/graph/validator/test/LookupValidatorTest.cpp index be9389db527..5c7b69656a1 100644 --- a/src/graph/validator/test/LookupValidatorTest.cpp +++ b/src/graph/validator/test/LookupValidatorTest.cpp @@ -136,6 +136,11 @@ TEST_F(LookupValidatorTest, wrongYield) { EXPECT_EQ(std::string(result.message()), "SyntaxError: please add alias when using `vertex'. near `vertex'"); } + { + std::string query = "LOOKUP ON person YIELD count(*)"; + auto result = checkResult(query); + EXPECT_EQ(std::string(result.message()), "SemanticError: illegal yield clauses `count(*)'"); + } { std::string query = "LOOKUP ON person YIELD vertex as node, edge"; auto result = checkResult(query); diff --git a/tests/tck/features/lookup/WithYield.feature b/tests/tck/features/lookup/WithYield.feature index b3a960f6270..3cacd5e1a04 100644 --- a/tests/tck/features/lookup/WithYield.feature +++ b/tests/tck/features/lookup/WithYield.feature @@ -90,3 +90,10 @@ Feature: Lookup with yield | "Marco Belinelli" | "Tony Parker" | 0 | 50 | [:like "Marco Belinelli"->"Tony Parker" @0 {likeness: 50}] | | "Rajon Rondo" | "Ray Allen" | 0 | -1 | [:like "Rajon Rondo"->"Ray Allen" @0 {likeness: -1}] | | "Ray Allen" | "Rajon Rondo" | 0 | 9 | [:like "Ray Allen"->"Rajon Rondo" @0 {likeness: 9}] | + When executing query: + """ + LOOKUP ON like WHERE like.likeness < 50 + 1 YIELD like.likeness, edge as relationship | YIELD count(*) as nums + """ + Then the result should be, in any order: + | nums | + | 6 | diff --git a/tests/tck/features/lookup/WithYield.intVid.feature b/tests/tck/features/lookup/WithYield.intVid.feature index 5d102620501..f685ca643d1 100644 --- a/tests/tck/features/lookup/WithYield.intVid.feature +++ b/tests/tck/features/lookup/WithYield.intVid.feature @@ -90,3 +90,11 @@ Feature: Lookup with yield in integer vid | "Marco Belinelli" | "Tony Parker" | 0 | 50 | [:like "Marco Belinelli"->"Tony Parker" @0 {likeness: 50}] | | "Rajon Rondo" | "Ray Allen" | 0 | -1 | [:like "Rajon Rondo"->"Ray Allen" @0 {likeness: -1}] | | "Ray Allen" | "Rajon Rondo" | 0 | 9 | [:like "Ray Allen"->"Rajon Rondo" @0 {likeness: 9}] | + When executing query: + """ + LOOKUP ON serve WHERE serve.start_year == 2008 and serve.end_year == 2019 + YIELD serve.start_year AS startYear | YIELD count(*) as nums + """ + Then the result should be, in any order: + | nums | + | 2 |