From 95bcf3e9004b7581deb58187d779b4fd29ab5085 Mon Sep 17 00:00:00 2001 From: Jiquan Long Date: Wed, 16 Aug 2023 20:20:17 +0800 Subject: [PATCH] Fix error message of proto parser not clear (#26365) Signed-off-by: longjiquan --- internal/core/src/query/PlanProto.cpp | 7 +++-- internal/core/unittest/CMakeLists.txt | 3 +- internal/core/unittest/test_plan_proto.cpp | 32 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 internal/core/unittest/test_plan_proto.cpp diff --git a/internal/core/src/query/PlanProto.cpp b/internal/core/src/query/PlanProto.cpp index 9996a00a9..b7b807841 100644 --- a/internal/core/src/query/PlanProto.cpp +++ b/internal/core/src/query/PlanProto.cpp @@ -699,8 +699,11 @@ ProtoParser::ParseExpr(const proto::plan::Expr& expr_pb) { case ppe::kJsonContainsExpr: { return ParseJsonContainsExpr(expr_pb.json_contains_expr()); } - default: - PanicInfo("unsupported expr proto node"); + default: { + std::string s; + google::protobuf::TextFormat::PrintToString(expr_pb, &s); + PanicInfo(std::string("unsupported expr proto node: ") + s); + } } } diff --git a/internal/core/unittest/CMakeLists.txt b/internal/core/unittest/CMakeLists.txt index 88093ba5e..6179b38b6 100644 --- a/internal/core/unittest/CMakeLists.txt +++ b/internal/core/unittest/CMakeLists.txt @@ -53,7 +53,8 @@ set(MILVUS_TEST_FILES test_integer_overflow.cpp test_offset_ordered_map.cpp test_offset_ordered_array.cpp - test_always_true_expr.cpp) + test_always_true_expr.cpp + test_plan_proto.cpp) if ( BUILD_DISK_ANN STREQUAL "ON" ) set(MILVUS_TEST_FILES diff --git a/internal/core/unittest/test_plan_proto.cpp b/internal/core/unittest/test_plan_proto.cpp new file mode 100644 index 000000000..e848e52d4 --- /dev/null +++ b/internal/core/unittest/test_plan_proto.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2019-2020 Zilliz. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License +// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +// or implied. See the License for the specific language governing permissions and limitations under the License + +#include +#include +#include +#include +#include + +#include "query/PlanProto.h" + +TEST(PlanProto, NotSetUnsupported) { + using namespace milvus; + using namespace milvus::query; + auto schema = std::make_shared(); + auto vec_fid = schema->AddDebugField( + "fakevec", DataType::VECTOR_FLOAT, 16, knowhere::metric::L2); + auto i64_fid = schema->AddDebugField("age", DataType::INT64); + schema->set_primary_field_id(i64_fid); + + proto::plan::Expr expr_pb; + ProtoParser parser(*schema); + ASSERT_ANY_THROW(parser.ParseExpr(expr_pb)); +} -- GitLab