diff --git a/src/graph/validator/FetchVerticesValidator.cpp b/src/graph/validator/FetchVerticesValidator.cpp index 0ae3e4f8649..3dbcd19eaa5 100644 --- a/src/graph/validator/FetchVerticesValidator.cpp +++ b/src/graph/validator/FetchVerticesValidator.cpp @@ -26,21 +26,6 @@ Status FetchVerticesValidator::validateImpl() { return Status::OK(); } -Expression *FetchVerticesValidator::rewriteIDVertex2Vid(const Expression *expr) { - auto *pool = qctx_->objPool(); - auto matcher = [](const Expression *e) -> bool { - std::string lowerStr = e->toString(); - folly::toLowerAscii(lowerStr); - return e->kind() == Expression::Kind::kFunctionCall && lowerStr == "id(vertex)"; - }; - auto rewriter = [pool](const Expression *e) -> Expression * { - UNUSED(e); - return InputPropertyExpression::make(pool, nebula::kVid); - }; - - return RewriteVisitor::transform(expr, std::move(matcher), std::move(rewriter)); -} - Status FetchVerticesValidator::validateTag(const NameLabelList *nameLabels) { if (nameLabels == nullptr) { // all tag @@ -89,21 +74,6 @@ Status FetchVerticesValidator::validateYield(YieldClause *yield) { } auto &exprProps = fetchCtx_->exprProps; - for (const auto &col : yield->columns()) { - if (col->expr()->kind() == Expression::Kind::kVertex) { - extractVertexProp(exprProps); - break; - } - auto *expr = ExpressionUtils::findAny(col->expr(), {Expression::Kind::kFunctionCall}); - if (expr != nullptr) { - const auto &name = static_cast(expr)->name(); - if (name == "properties") { - extractVertexProp(exprProps); - break; - } - } - } - for (auto col : yield->columns()) { if (ExpressionUtils::hasAny(col->expr(), {Expression::Kind::kEdge, Expression::Kind::kPathBuild})) { @@ -111,13 +81,17 @@ Status FetchVerticesValidator::validateYield(YieldClause *yield) { } col->setExpr(ExpressionUtils::rewriteLabelAttr2TagProp(col->expr())); NG_RETURN_IF_ERROR(ValidateUtil::invalidLabelIdentifiers(col->expr())); + auto colExpr = col->expr(); auto typeStatus = deduceExprType(colExpr); NG_RETURN_IF_ERROR(typeStatus); outputs_.emplace_back(col->name(), typeStatus.value()); - if (colExpr->kind() == Expression::Kind::kFunctionCall) { + if (colExpr->toString() == "id(VERTEX)") { col->setAlias(col->name()); - col->setExpr(rewriteIDVertex2Vid(colExpr)); + col->setExpr(InputPropertyExpression::make(pool, nebula::kVid)); + } + if (ExpressionUtils::hasAny(colExpr, {Expression::Kind::kVertex})) { + extractVertexProp(exprProps); } newCols->addColumn(col->clone().release()); diff --git a/src/graph/validator/FetchVerticesValidator.h b/src/graph/validator/FetchVerticesValidator.h index 608aa39ffd7..fda754f393d 100644 --- a/src/graph/validator/FetchVerticesValidator.h +++ b/src/graph/validator/FetchVerticesValidator.h @@ -30,8 +30,6 @@ class FetchVerticesValidator final : public Validator { void extractVertexProp(ExpressionProps& exprProps); - Expression* rewriteIDVertex2Vid(const Expression* expr); - private: std::map> tagsSchema_; diff --git a/tests/tck/features/fetch/FetchVertices.intVid.feature b/tests/tck/features/fetch/FetchVertices.intVid.feature index f07fe4fe3f6..5db3ff79de8 100644 --- a/tests/tck/features/fetch/FetchVertices.intVid.feature +++ b/tests/tck/features/fetch/FetchVertices.intVid.feature @@ -409,3 +409,10 @@ Feature: Fetch Int Vid Vertices Then the result should be, in any order, and the columns 0, 1 should be hashed: | VertexID | id(VERTEX) | name | properties(VERTEX) | | "Tim Duncan" | "Tim Duncan" | "Tim Duncan" | {age: 42, name: "Tim Duncan"} | + When executing query: + """ + FETCH PROP ON player hash('Tim Duncan') YIELD id(vertex), keys(vertex) as keys, tags(vertex) as tagss, properties(vertex) as props + """ + Then the result should be, in any order, and the columns 0, 1 should be hashed: + | VertexID | id(VERTEX) | keys | tagss | props | + | "Tim Duncan" | "Tim Duncan" | ["age", "name", "speciality"] | ["bachelor", "player"] | {age: 42, name: "Tim Duncan", speciality: "psychology"} | diff --git a/tests/tck/features/fetch/FetchVertices.strVid.feature b/tests/tck/features/fetch/FetchVertices.strVid.feature index d9479df7c5a..d356e3731f0 100644 --- a/tests/tck/features/fetch/FetchVertices.strVid.feature +++ b/tests/tck/features/fetch/FetchVertices.strVid.feature @@ -520,3 +520,10 @@ Feature: Fetch String Vertices Then the result should be, in any order: | VertexID | id(VERTEX) | name | properties(VERTEX) | | "Tim Duncan" | "Tim Duncan" | "Tim Duncan" | {age: 42, name: "Tim Duncan"} | + When executing query: + """ + FETCH PROP ON player 'Tim Duncan' YIELD id(vertex), keys(vertex) as keys, tags(vertex) as tagss, properties(vertex) as props + """ + Then the result should be, in any order: + | VertexID | id(VERTEX) | keys | tagss | props | + | "Tim Duncan" | "Tim Duncan" | ["age", "name", "speciality"] | ["bachelor", "player"] | {age: 42, name: "Tim Duncan", speciality: "psychology"} |