Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/fetch-vertices-on-multi-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg committed Oct 26, 2020
2 parents 490f6b8 + f87d590 commit 546edae
Show file tree
Hide file tree
Showing 25 changed files with 195 additions and 307 deletions.
1 change: 1 addition & 0 deletions src/context/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SET(CONTEXT_TEST_LIBS
$<TARGET_OBJECTS:common_time_function_obj>
$<TARGET_OBJECTS:common_http_client_obj>
$<TARGET_OBJECTS:common_process_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
$<TARGET_OBJECTS:util_obj>
$<TARGET_OBJECTS:context_obj>
$<TARGET_OBJECTS:expr_visitor_obj>
Expand Down
1 change: 1 addition & 0 deletions src/daemons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ nebula_add_executable(
$<TARGET_OBJECTS:common_function_manager_obj>
$<TARGET_OBJECTS:common_agg_function_obj>
$<TARGET_OBJECTS:common_conf_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
LIBRARIES
proxygenhttpserver
proxygenlib
Expand Down
1 change: 1 addition & 0 deletions src/executor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SET(EXEC_QUERY_TEST_OBJS
$<TARGET_OBJECTS:common_agg_function_obj>
$<TARGET_OBJECTS:common_encryption_obj>
$<TARGET_OBJECTS:common_http_client_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
$<TARGET_OBJECTS:session_obj>
$<TARGET_OBJECTS:graph_flags_obj>
$<TARGET_OBJECTS:parser_obj>
Expand Down
1 change: 1 addition & 0 deletions src/mock/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(GRAPH_TEST_LIB
$<TARGET_OBJECTS:common_http_client_obj>
$<TARGET_OBJECTS:common_encryption_obj>
$<TARGET_OBJECTS:common_agg_function_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
)

nebula_add_test(
Expand Down
1 change: 1 addition & 0 deletions src/optimizer/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(OPTIMIZER_TEST_LIB
$<TARGET_OBJECTS:common_http_client_obj>
$<TARGET_OBJECTS:common_process_obj>
$<TARGET_OBJECTS:common_agg_function_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
$<TARGET_OBJECTS:idgenerator_obj>
$<TARGET_OBJECTS:expr_visitor_obj>
$<TARGET_OBJECTS:session_obj>
Expand Down
1 change: 1 addition & 0 deletions src/parser/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ set(PARSER_TEST_LIBS
$<TARGET_OBJECTS:common_charset_obj>
$<TARGET_OBJECTS:common_file_based_cluster_id_man_obj>
$<TARGET_OBJECTS:common_process_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
$<TARGET_OBJECTS:session_obj>
$<TARGET_OBJECTS:graph_flags_obj>
$<TARGET_OBJECTS:graph_auth_obj>
Expand Down
1 change: 1 addition & 0 deletions src/util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nebula_add_test(
$<TARGET_OBJECTS:common_http_client_obj>
$<TARGET_OBJECTS:common_process_obj>
$<TARGET_OBJECTS:common_agg_function_obj>
$<TARGET_OBJECTS:common_time_utils_obj>
$<TARGET_OBJECTS:idgenerator_obj>
$<TARGET_OBJECTS:expr_visitor_obj>
$<TARGET_OBJECTS:session_obj>
Expand Down
32 changes: 20 additions & 12 deletions src/validator/ACLValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ static std::size_t kPasswordMaxLength = 24;
Status CreateUserValidator::validateImpl() {
const auto *sentence = static_cast<const CreateUserSentence *>(sentence_);
if (sentence->getAccount()->size() > kUsernameMaxLength) {
return Status::Error("Username exceed maximum length %ld characters.", kUsernameMaxLength);
return Status::SemanticError("Username exceed maximum length %ld characters.",
kUsernameMaxLength);
}
if (sentence->getPassword()->size() > kPasswordMaxLength) {
return Status::Error("Password exceed maximum length %ld characters.", kPasswordMaxLength);
return Status::SemanticError("Password exceed maximum length %ld characters.",
kPasswordMaxLength);
}
return Status::OK();
}
Expand All @@ -40,7 +42,8 @@ Status CreateUserValidator::toPlan() {
Status DropUserValidator::validateImpl() {
const auto *sentence = static_cast<const DropUserSentence *>(sentence_);
if (sentence->getAccount()->size() > kUsernameMaxLength) {
return Status::Error("Username exceed maximum length %ld characters.", kUsernameMaxLength);
return Status::SemanticError("Username exceed maximum length %ld characters.",
kUsernameMaxLength);
}
return Status::OK();
}
Expand All @@ -54,10 +57,12 @@ Status DropUserValidator::toPlan() {
Status UpdateUserValidator::validateImpl() {
const auto *sentence = static_cast<const AlterUserSentence *>(sentence_);
if (sentence->getAccount()->size() > kUsernameMaxLength) {
return Status::Error("Username exceed maximum length %ld characters.", kUsernameMaxLength);
return Status::SemanticError("Username exceed maximum length %ld characters.",
kUsernameMaxLength);
}
if (sentence->getPassword()->size() > kPasswordMaxLength) {
return Status::Error("Password exceed maximum length %ld characters.", kPasswordMaxLength);
return Status::SemanticError("Password exceed maximum length %ld characters.",
kPasswordMaxLength);
}
return Status::OK();
}
Expand All @@ -80,15 +85,16 @@ Status ShowUsersValidator::toPlan() {
Status ChangePasswordValidator::validateImpl() {
const auto *sentence = static_cast<const ChangePasswordSentence *>(sentence_);
if (sentence->getAccount()->size() > kUsernameMaxLength) {
return Status::Error("Username exceed maximum length %ld characters.", kUsernameMaxLength);
return Status::SemanticError("Username exceed maximum length %ld characters.",
kUsernameMaxLength);
}
if (sentence->getOldPwd()->size() > kPasswordMaxLength) {
return Status::Error("Old password exceed maximum length %ld characters.",
kPasswordMaxLength);
return Status::SemanticError("Old password exceed maximum length %ld characters.",
kPasswordMaxLength);
}
if (sentence->getNewPwd()->size() > kPasswordMaxLength) {
return Status::Error("New password exceed maximum length %ld characters.",
kPasswordMaxLength);
return Status::SemanticError("New password exceed maximum length %ld characters.",
kPasswordMaxLength);
}
return Status::OK();
}
Expand All @@ -103,7 +109,8 @@ Status ChangePasswordValidator::toPlan() {
Status GrantRoleValidator::validateImpl() {
const auto *sentence = static_cast<const GrantSentence *>(sentence_);
if (sentence->getAccount()->size() > kUsernameMaxLength) {
return Status::Error("Username exceed maximum length %ld characters.", kUsernameMaxLength);
return Status::SemanticError("Username exceed maximum length %ld characters.",
kUsernameMaxLength);
}
return Status::OK();
}
Expand All @@ -119,7 +126,8 @@ Status GrantRoleValidator::toPlan() {
Status RevokeRoleValidator::validateImpl() {
const auto *sentence = static_cast<const RevokeSentence *>(sentence_);
if (sentence->getAccount()->size() > kUsernameMaxLength) {
return Status::Error("Username exceed maximum length %ld characters.", kUsernameMaxLength);
return Status::SemanticError("Username exceed maximum length %ld characters.",
kUsernameMaxLength);
}
return Status::OK();
}
Expand Down
20 changes: 11 additions & 9 deletions src/validator/AdminValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ Status CreateSpaceValidator::validateImpl() {
case SpaceOptItem::PARTITION_NUM: {
spaceDesc_.partition_num = item->getPartitionNum();
if (spaceDesc_.partition_num <= 0) {
return Status::Error("Partition_num value should be greater than zero");
return Status::SemanticError("Partition_num value should be greater than zero");
}
break;
}
case SpaceOptItem::REPLICA_FACTOR: {
spaceDesc_.replica_factor = item->getReplicaFactor();
if (spaceDesc_.replica_factor <= 0) {
return Status::Error("Replica_factor value should be greater than zero");
return Status::SemanticError(
"Replica_factor value should be greater than zero");
}
break;
}
Expand All @@ -48,18 +49,19 @@ Status CreateSpaceValidator::validateImpl() {
std::stringstream ss;
ss << "Only support FIXED_STRING or INT64 vid type, but was given "
<< meta::cpp2::_PropertyType_VALUES_TO_NAMES.at(typeDef.type);
return Status::Error(ss.str());
return Status::SemanticError(ss.str());
}
spaceDesc_.vid_type.set_type(typeDef.type);

if (typeDef.type == meta::cpp2::PropertyType::INT64) {
spaceDesc_.vid_type.set_type_length(8);
} else {
if (!typeDef.__isset.type_length) {
return Status::Error("type length is not set for fixed string type");
return Status::SemanticError(
"type length is not set for fixed string type");
}
if (*typeDef.get_type_length() <= 0) {
return Status::Error("Vid size should be a positive number: %d",
return Status::SemanticError("Vid size should be a positive number: %d",
*typeDef.get_type_length());
}
spaceDesc_.vid_type.set_type_length(*typeDef.get_type_length());
Expand Down Expand Up @@ -294,7 +296,7 @@ Status SetConfigValidator::validateImpl() {
auto sentence = static_cast<SetConfigSentence*>(sentence_);
auto item = sentence->configItem();
if (item == nullptr) {
return Status::Error("Empty config item");
return Status::SemanticError("Empty config item");
}
if (item->getName() != nullptr) {
name_ = *item->getName();
Expand All @@ -318,14 +320,14 @@ Status SetConfigValidator::validateImpl() {
std::string name;
Value value;
if (updateItem->getFieldName() == nullptr || updateItem->value() == nullptr) {
return Status::Error("Empty item");
return Status::SemanticError("Empty item");
}
name = *updateItem->getFieldName();

value = Expression::eval(const_cast<Expression*>(updateItem->value()), ctx(nullptr));

if (value.isNull() || (!value.isNumeric() && !value.isStr() && !value.isBool())) {
return Status::Error("Wrong value: %s", name.c_str());
return Status::SemanticError("Wrong value: `%s'", name.c_str());
}
configs.kvs.emplace(std::move(name), std::move(value));
}
Expand All @@ -350,7 +352,7 @@ Status GetConfigValidator::validateImpl() {
auto sentence = static_cast<GetConfigSentence*>(sentence_);
auto item = sentence->configItem();
if (item == nullptr) {
return Status::Error("Empty config item");
return Status::SemanticError("Empty config item");
}

module_ = item->getModule();
Expand Down
19 changes: 10 additions & 9 deletions src/validator/FetchEdgesValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Status FetchEdgesValidator::check() {
schema_ = qctx_->schemaMng()->getEdgeSchema(spaceId_, edgeType_);
if (schema_ == nullptr) {
LOG(ERROR) << "No schema found for " << sentence->edge();
return Status::Error("No schema found for `%s'", sentence->edge()->c_str());
return Status::SemanticError("No schema found for `%s'", sentence->edge()->c_str());
}

return Status::OK();
Expand All @@ -106,14 +106,15 @@ Status FetchEdgesValidator::prepareEdges() {
result = checkRef(rankRef_, Value::Type::INT);
NG_RETURN_IF_ERROR(result);
if (inputVar_ != result.value()) {
return Status::Error("Can't refer to different variable as key at same time.");
return Status::SemanticError(
"Can't refer to different variable as key at same time.");
}
}
dstRef_ = sentence->ref()->dstid();
result = checkRef(dstRef_, Value::Type::STRING);
NG_RETURN_IF_ERROR(result);
if (inputVar_ != result.value()) {
return Status::Error("Can't refer to different variable as key at same time.");
return Status::SemanticError("Can't refer to different variable as key at same time.");
}
return Status::OK();
}
Expand Down Expand Up @@ -188,25 +189,25 @@ Status FetchEdgesValidator::preparePropertiesWithYield(const YieldClause *yield)
}
const auto *invalidExpr = findInvalidYieldExpression(col->expr());
if (invalidExpr != nullptr) {
return Status::Error("Invalid newYield_ expression `%s'.",
col->expr()->toString().c_str());
return Status::SemanticError("Invalid newYield_ expression `%s'.",
col->expr()->toString().c_str());
}
// The properties from storage directly push down only
// The other will be computed in Project Executor
const auto storageExprs = ExpressionUtils::findAllStorage(col->expr());
for (const auto &storageExpr : storageExprs) {
const auto *expr = static_cast<const PropertyExpression *>(storageExpr);
if (*expr->sym() != edgeTypeName_) {
return Status::Error("Mismatched edge type name");
return Status::SemanticError("Mismatched edge type name");
}
// Check is prop name in schema
if (schema_->getFieldIndex(*expr->prop()) < 0 &&
reservedProperties.find(*expr->prop()) == reservedProperties.end()) {
LOG(ERROR) << "Unknown column `" << *expr->prop() << "' in edge `" << edgeTypeName_
<< "'.";
return Status::Error("Unknown column `%s' in edge `%s'",
expr->prop()->c_str(),
edgeTypeName_.c_str());
return Status::SemanticError("Unknown column `%s' in edge `%s'",
expr->prop()->c_str(),
edgeTypeName_.c_str());
}
propsName.emplace_back(*expr->prop());
geColNames_.emplace_back(*expr->sym() + "." + *expr->prop());
Expand Down
11 changes: 6 additions & 5 deletions src/validator/FetchVerticesValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Status FetchVerticesValidator::check() {
auto schema = qctx_->schemaMng()->getTagSchema(space_.id, tagId);
if (schema == nullptr) {
LOG(ERROR) << "No schema found for " << *tag;
return Status::Error("No schema found for `%s'", tag->c_str());
return Status::SemanticError("No schema found for `%s'", tag->c_str());
}
tagsSchema_.emplace(tagId, schema);
}
Expand Down Expand Up @@ -159,13 +159,14 @@ Status FetchVerticesValidator::preparePropertiesWithYield(const YieldClause *yie
return std::move(deducePropsVisitor).status();
}
if (exprProps.hasInputVarProperty()) {
return Status::Error("Unsupported input/variable property expression in yield.");
return Status::SemanticError(
"Unsupported input/variable property expression in yield.");
}
if (!exprProps.edgeProps().empty()) {
return Status::Error("Unsupported edge property expression in yield.");
return Status::SemanticError("Unsupported edge property expression in yield.");
}
if (exprProps.hasSrcDstTagProperty()) {
return Status::Error("Unsupported src/dst property expression in yield.");
return Status::SemanticError("Unsupported src/dst property expression in yield.");
}

colNames_.emplace_back(deduceColName(col));
Expand All @@ -175,7 +176,7 @@ Status FetchVerticesValidator::preparePropertiesWithYield(const YieldClause *yie
// TODO(shylock) think about the push-down expr
}
if (exprProps.tagProps().empty()) {
return Status::Error("Unsupported empty tag property expression in yield.");
return Status::SemanticError("Unsupported empty tag property expression in yield.");
}

if (onStar_) {
Expand Down
48 changes: 11 additions & 37 deletions src/validator/GetSubgraphValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,13 @@ namespace nebula {
namespace graph {

Status GetSubgraphValidator::validateImpl() {
Status status;
auto* gsSentence = static_cast<GetSubgraphSentence*>(sentence_);

status = validateStep(gsSentence->step(), steps_);
if (!status.ok()) {
return status;
}

status = validateStarts(gsSentence->from(), from_);
if (!status.ok()) {
return status;
}

status = validateInBound(gsSentence->in());
if (!status.ok()) {
return status;
}

status = validateOutBound(gsSentence->out());
if (!status.ok()) {
return status;
}

status = validateBothInOutBound(gsSentence->both());
if (!status.ok()) {
return status;
}
NG_RETURN_IF_ERROR(validateStep(gsSentence->step(), steps_));
NG_RETURN_IF_ERROR(validateStarts(gsSentence->from(), from_));
NG_RETURN_IF_ERROR(validateInBound(gsSentence->in()));
NG_RETURN_IF_ERROR(validateOutBound(gsSentence->out()));
NG_RETURN_IF_ERROR(validateBothInOutBound(gsSentence->both()));

return Status::OK();
}
Expand All @@ -56,13 +36,11 @@ Status GetSubgraphValidator::validateInBound(InBoundClause* in) {
edgeTypes_.reserve(edgeTypes_.size() + edges.size());
for (auto* e : edges) {
if (e->alias() != nullptr) {
return Status::Error("Get Subgraph not support rename edge name.");
return Status::SemanticError("Get Subgraph not support rename edge name.");
}

auto et = qctx_->schemaMng()->toEdgeType(space.id, *e->edge());
if (!et.ok()) {
return et.status();
}
NG_RETURN_IF_ERROR(et);

auto v = -et.value();
edgeTypes_.emplace(v);
Expand All @@ -79,13 +57,11 @@ Status GetSubgraphValidator::validateOutBound(OutBoundClause* out) {
edgeTypes_.reserve(edgeTypes_.size() + edges.size());
for (auto* e : out->edges()) {
if (e->alias() != nullptr) {
return Status::Error("Get Subgraph not support rename edge name.");
return Status::SemanticError("Get Subgraph not support rename edge name.");
}

auto et = qctx_->schemaMng()->toEdgeType(space.id, *e->edge());
if (!et.ok()) {
return et.status();
}
NG_RETURN_IF_ERROR(et);

edgeTypes_.emplace(et.value());
}
Expand All @@ -101,13 +77,11 @@ Status GetSubgraphValidator::validateBothInOutBound(BothInOutClause* out) {
edgeTypes_.reserve(edgeTypes_.size() + edges.size());
for (auto* e : out->edges()) {
if (e->alias() != nullptr) {
return Status::Error("Get Subgraph not support rename edge name.");
return Status::SemanticError("Get Subgraph not support rename edge name.");
}

auto et = qctx_->schemaMng()->toEdgeType(space.id, *e->edge());
if (!et.ok()) {
return et.status();
}
NG_RETURN_IF_ERROR(et);

auto v = et.value();
edgeTypes_.emplace(v);
Expand Down
Loading

0 comments on commit 546edae

Please sign in to comment.