HappenLee commented on a change in pull request #8494: URL: https://github.com/apache/incubator-doris/pull/8494#discussion_r827883490
########## File path: be/test/test_util/array_utils.cpp ########## @@ -0,0 +1,72 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 "test_util/array_utils.h" + +#include "common/status.h" +#include "exprs/anyval_util.h" +#include "gen_cpp/olap_file.pb.h" +#include "runtime/collection_value.h" +#include "runtime/free_pool.hpp" +#include "runtime/mem_pool.h" +#include "runtime/mem_tracker.h" +#include "udf/udf_internal.h" +#include "util/array_parser.hpp" + +namespace doris { + +using TypeDesc = FunctionContext::TypeDesc; + +void ArrayUtils::prepare_context(FunctionContext& context, MemPool& mem_pool, + const ColumnPB& column_pb) { + auto function_type_desc = create_function_type_desc(column_pb); + context.impl()->_return_type = function_type_desc; + context.impl()->_pool = new FreePool(&mem_pool); +} + +Status ArrayUtils::create_collection_value(CollectionValue* collection_value, + FunctionContext* context, + const std::string& json_string) { + CollectionVal collection_val; + auto status = ArrayParser::parse(collection_val, context, StringVal(json_string.c_str())); + if (!status.ok()) { + return status; + } + new (collection_value) CollectionValue(collection_val.data, collection_val.length, + collection_val.has_null, collection_val.null_signs); + return Status::OK(); +} + +TypeDesc ArrayUtils::create_function_type_desc(const ColumnPB& column_pb) { + TypeDesc type_desc; + type_desc.len = column_pb.length(); + type_desc.precision = column_pb.precision(); + type_desc.scale = column_pb.frac(); + if (column_pb.type() == "ARRAY") { Review comment: if the code only use in unit test,move it to test dir please -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org