// 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 || IsDecimal> struct BitOrImpl; template struct BitOrImpl { using ResultType = typename NumberTraits::ResultOfBit::Type; template static Result apply(A a, B b) { return static_cast(a) | static_cast(b); } template static Result apply(A, B, UInt8 &) { throw Exception("Should not reach here"); } }; template struct BitOrImpl { using ResultType = If || std::is_unsigned_v, uint64_t, int64_t>; template static Result apply(A a, B b) { Result x, y; if constexpr (IsDecimal) { x = static_cast(a.value); } else { x = static_cast(a); } if constexpr (IsDecimal) { y = static_cast(b.value); } else { y = static_cast(b); } return BitOrImpl::apply(x, y); } template static Result apply(A, B, UInt8 &) { throw Exception("Should not reach here"); } }; // clang-format off struct NameBitOr { static constexpr auto name = "bitOr"; }; // clang-format on template using BitOrImpl_t = BitOrImpl; using FunctionBitOr = FunctionBinaryArithmetic; } // namespace void registerFunctionBitOr(FunctionFactory & factory) { factory.registerFunction(); } } // namespace DB