Skip to content

Commit

Permalink
[fix][store] Remove restrict for empty pb_schema. (dingodb#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasyard authored Dec 6, 2023
1 parent 825e8c4 commit 7962399
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/coprocessor/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ void SerialBaseSchemaUpdateKeyWrapper(bool is_key, const UPDATE& update, SERIAL_
}

butil::Status Utils::CheckPbSchema(const google::protobuf::RepeatedPtrField<pb::store::Schema>& pb_schemas) {
if (pb_schemas.empty()) {
std::string error_message = fmt::format("pb_schema empty. not support");
DINGO_LOG(ERROR) << error_message;
return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
}
// if (pb_schemas.empty()) {
// std::string error_message = fmt::format("pb_schema empty. not support");
// DINGO_LOG(ERROR) << error_message;
// return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
// }

size_t i = 0;
for (const auto& schema : pb_schemas) {
Expand Down Expand Up @@ -104,11 +104,11 @@ butil::Status Utils::CheckPbSchema(const google::protobuf::RepeatedPtrField<pb::

butil::Status Utils::CheckSerialSchema(
const std::shared_ptr<std::vector<std::shared_ptr<BaseSchema>>>& serial_schemas) {
if (serial_schemas && serial_schemas->empty()) {
std::string error_message = fmt::format("serial_schemas empty. not support");
DINGO_LOG(ERROR) << error_message;
return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
}
// if (serial_schemas && serial_schemas->empty()) {
// std::string error_message = fmt::format("serial_schemas empty. not support");
// DINGO_LOG(ERROR) << error_message;
// return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
// }

size_t i = 0;
for (const auto& schema : *serial_schemas) {
Expand Down
6 changes: 3 additions & 3 deletions test/test_coprocessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ TEST_F(CoprocessorTest, Open) {
pb_coprocessor.set_schema_version(1);

ok = coprocessor->Open(pb_coprocessor);
EXPECT_EQ(ok.error_code(), pb::error::EILLEGAL_PARAMTETERS);
EXPECT_EQ(ok.error_code(), pb::error::Errno::OK);
}

// selection empty failed
Expand Down Expand Up @@ -225,7 +225,7 @@ TEST_F(CoprocessorTest, Open) {
}

ok = coprocessor->Open(pb_coprocessor);
EXPECT_EQ(ok.error_code(), pb::error::EILLEGAL_PARAMTETERS);
EXPECT_EQ(ok.error_code(), pb::error::Errno::OK);
}

// result empty failed
Expand Down Expand Up @@ -300,7 +300,7 @@ TEST_F(CoprocessorTest, Open) {
selection_columns->Add(5);

ok = coprocessor->Open(pb_coprocessor);
EXPECT_EQ(ok.error_code(), pb::error::EILLEGAL_PARAMTETERS);
EXPECT_EQ(ok.error_code(), pb::error::Errno::OK);
}

// ok but not exist aggregation
Expand Down
10 changes: 5 additions & 5 deletions test/test_coprocessor_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class CoprocessorUtilsTest : public testing::Test {
};

TEST_F(CoprocessorUtilsTest, CheckPbSchema) {
// empty failed
// empty ok
{
google::protobuf::RepeatedPtrField<pb::store::Schema> pb_schemas;
butil::Status ok = Utils::CheckPbSchema(pb_schemas);
EXPECT_EQ(ok.error_code(), pb::error::Errno::EILLEGAL_PARAMTETERS);
EXPECT_EQ(ok.error_code(), pb::error::Errno::OK);
}

// type invalid
Expand All @@ -60,7 +60,7 @@ TEST_F(CoprocessorUtilsTest, CheckPbSchema) {
schema1.set_index(0);
pb_schemas.Add(std::move(schema1));
butil::Status ok = Utils::CheckPbSchema(pb_schemas);
EXPECT_EQ(ok.error_code(), pb::error::Errno::EILLEGAL_PARAMTETERS);
EXPECT_EQ(ok.error_code(), pb::error::Errno::OK);
}

// index invalid
Expand Down Expand Up @@ -151,12 +151,12 @@ TEST_F(CoprocessorUtilsTest, CheckPbSchema) {
}

TEST_F(CoprocessorUtilsTest, CheckSelection) {
// empty failed
// empty ok
{
::google::protobuf::RepeatedField<int32_t> selection_columns;
size_t original_schema_size = 10;
butil::Status ok = Utils::CheckSelection(selection_columns, 10);
EXPECT_EQ(ok.error_code(), pb::error::Errno::EILLEGAL_PARAMTETERS);
EXPECT_EQ(ok.error_code(), pb::error::Errno::OK);
}

// index = -1 invalid
Expand Down

0 comments on commit 7962399

Please sign in to comment.