From 796239961e84c5da82329195f54a06b5dc7adb85 Mon Sep 17 00:00:00 2001 From: Yueguang Jiao Date: Wed, 6 Dec 2023 17:07:50 +0800 Subject: [PATCH] [fix][store] Remove restrict for empty pb_schema. (#746) --- src/coprocessor/utils.cc | 20 ++++++++++---------- test/test_coprocessor.cc | 6 +++--- test/test_coprocessor_utils.cc | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/coprocessor/utils.cc b/src/coprocessor/utils.cc index 412aa473a..1c7171111 100755 --- a/src/coprocessor/utils.cc +++ b/src/coprocessor/utils.cc @@ -70,11 +70,11 @@ void SerialBaseSchemaUpdateKeyWrapper(bool is_key, const UPDATE& update, SERIAL_ } butil::Status Utils::CheckPbSchema(const google::protobuf::RepeatedPtrField& 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) { @@ -104,11 +104,11 @@ butil::Status Utils::CheckPbSchema(const google::protobuf::RepeatedPtrField>>& 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) { diff --git a/test/test_coprocessor.cc b/test/test_coprocessor.cc index 5a6d93b55..8788e317e 100644 --- a/test/test_coprocessor.cc +++ b/test/test_coprocessor.cc @@ -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 @@ -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 @@ -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 diff --git a/test/test_coprocessor_utils.cc b/test/test_coprocessor_utils.cc index a8e7e32f6..82229a8ce 100644 --- a/test/test_coprocessor_utils.cc +++ b/test/test_coprocessor_utils.cc @@ -43,11 +43,11 @@ class CoprocessorUtilsTest : public testing::Test { }; TEST_F(CoprocessorUtilsTest, CheckPbSchema) { - // empty failed + // empty ok { google::protobuf::RepeatedPtrField 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 @@ -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 @@ -151,12 +151,12 @@ TEST_F(CoprocessorUtilsTest, CheckPbSchema) { } TEST_F(CoprocessorUtilsTest, CheckSelection) { - // empty failed + // empty ok { ::google::protobuf::RepeatedField 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