Skip to content

Commit

Permalink
check vidtyp
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Jul 23, 2022
1 parent f8dd6b7 commit 47751ce
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/graph/executor/query/AppendVerticesExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DataSet AppendVerticesExecutor::buildRequestDataSet(const AppendVertices *av) {
return nebula::DataSet({kVid});
}
auto valueIter = ectx_->getResult(av->inputVar()).iter();
return buildRequestDataSetByVidType(valueIter.get(), av->src(), av->dedup());
return buildRequestDataSetByVidType(valueIter.get(), av->src(), av->dedup(), true);
}

folly::Future<Status> AppendVerticesExecutor::appendVertices() {
Expand Down
1 change: 1 addition & 0 deletions src/graph/executor/query/GetEdgesExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "graph/executor/query/GetEdgesExecutor.h"

#include "graph/planner/plan/Query.h"
#include "graph/util/SchemaUtil.h"

using nebula::storage::StorageClient;
using nebula::storage::StorageRpcResponse;
Expand Down
18 changes: 13 additions & 5 deletions src/graph/validator/FetchEdgesValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Status FetchEdgesValidator::validateEdgeName() {

// Check validity of edge key(src, type, rank, dst)
// from Input/Variable expression specified in sentence
StatusOr<std::string> FetchEdgesValidator::validateEdgeRef(const Expression *expr,
Value::Type type) {
StatusOr<std::string> FetchEdgesValidator::validateEdgeRef(const Expression *expr) {
const auto &kind = expr->kind();
if (kind != Expression::Kind::kInputProperty && kind != EdgeExpression::Kind::kVarProperty) {
return Status::SemanticError("`%s', only input and variable expression is acceptable",
Expand Down Expand Up @@ -72,13 +71,22 @@ Status FetchEdgesValidator::validateEdgeKey() {
std::string inputVarName;
if (sentence->isRef()) { // edge keys from Input/Variable
auto *srcExpr = sentence->ref()->srcid();
auto result = validateEdgeRef(srcExpr, vidType_);
auto result = validateEdgeRef(srcExpr);
NG_RETURN_IF_ERROR(result);
inputVarName = std::move(result).value();

auto *rankExpr = sentence->ref()->rank();
if (rankExpr->kind() != Expression::Kind::kConstant) {
result = validateEdgeRef(rankExpr, Value::Type::INT);
auto rankType = deduceExprType(rankExpr);
NG_RETURN_IF_ERROR(rankType);
if (rankType.value() != Value::Type::INT) {
std::stringstream ss;
ss << "`" << rankExpr->toString() << "' should be type of INT, but was "
<< rankType.value();
return Status::SemanticError(ss.str());
}

result = validateEdgeRef(rankExpr);
NG_RETURN_IF_ERROR(result);
if (inputVarName != result.value()) {
return Status::SemanticError(
Expand All @@ -88,7 +96,7 @@ Status FetchEdgesValidator::validateEdgeKey() {
}

auto *dstExpr = sentence->ref()->dstid();
result = validateEdgeRef(dstExpr, vidType_);
result = validateEdgeRef(dstExpr);
NG_RETURN_IF_ERROR(result);
if (inputVarName != result.value()) {
return Status::SemanticError(
Expand Down
2 changes: 1 addition & 1 deletion src/graph/validator/FetchEdgesValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FetchEdgesValidator final : public Validator {

Status validateEdgeName();

StatusOr<std::string> validateEdgeRef(const Expression* expr, Value::Type type);
StatusOr<std::string> validateEdgeRef(const Expression* expr);

Status validateEdgeKey();

Expand Down
6 changes: 2 additions & 4 deletions src/graph/validator/test/GetSubgraphValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,15 @@ TEST_F(GetSubgraphValidatorTest, RefNotExist) {
"PROP FROM $-.id YIELD vertices as nodes";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()),
"SemanticError: `$-.id', the srcs should be type of "
"FIXED_STRING, but was`INT'");
"SemanticError: `$-.id', the srcs should be type of FIXED_STRING, but was`INT'");
}
{
std::string query =
"$a = GO FROM \"1\" OVER like YIELD $$.person.age AS ID; GET SUBGRAPH "
"FROM $a.ID YIELD edges as relationships";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()),
"SemanticError: `$a.ID', the srcs should be type of "
"FIXED_STRING, but was`INT'");
"SemanticError: `$a.ID', the srcs should be type of FIXED_STRING, but was`INT'");
}
{
std::string query =
Expand Down

0 comments on commit 47751ce

Please sign in to comment.