// 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. // This file is copied from // https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/FunctionUnaryArithmetic.h // and modified by Doris #pragma once #include "vec/columns/column_decimal.h" #include "vec/columns/column_vector.h" #include "vec/data_types/data_type_decimal.h" #include "vec/data_types/data_type_number.h" #include "vec/functions/cast_type_to_either.h" #include "vec/functions/function.h" #include "vec/functions/function_helpers.h" namespace doris::vectorized { template struct UnaryOperationImpl { using ResultType = typename Op::ResultType; using ColVecA = std::conditional_t, ColumnDecimal, ColumnVector>; using ColVecC = std::conditional_t, ColumnDecimal, ColumnVector>; using ArrayA = typename ColVecA::Container; using ArrayC = typename ColVecC::Container; static void NO_INLINE vector(const ArrayA& a, ArrayC& c) { size_t size = a.size(); for (size_t i = 0; i < size; ++i) c[i] = Op::apply(a[i]); } static void constant(A a, ResultType& c) { c = Op::apply(a); } }; template struct FunctionUnaryArithmeticMonotonicity; template struct AbsImpl; template struct NegativeImpl; template struct PositiveImpl; /// Used to indicate undefined operation struct InvalidType; template