// Copyright 2023 PingCAP, Inc. // // 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 namespace DB { namespace { template struct IntExp2Impl { using ResultType = UInt64; static ResultType apply(A a) { return intExp2(a); } }; template struct IntExp2Impl> { using ResultType = UInt64; static ResultType apply(Decimal) { return 0; } }; // clang-format off struct NameIntExp2 { static constexpr auto name = "intExp2"; }; // clang-format on using FunctionIntExp2 = FunctionUnaryArithmetic; } // namespace template <> struct FunctionUnaryArithmeticMonotonicity { static bool has() { return true; } static IFunction::Monotonicity get(const Field & left, const Field & right) { Float64 left_float = left.isNull() ? -std::numeric_limits::infinity() : applyVisitor(FieldVisitorConvertToNumber(), left); Float64 right_float = right.isNull() ? std::numeric_limits::infinity() : applyVisitor(FieldVisitorConvertToNumber(), right); if (left_float < 0 || right_float > 63) return {}; return {true}; } }; void registerFunctionIntExp2(FunctionFactory & factory) { factory.registerFunction(); } } // namespace DB