mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
fixed result type trait
This commit is contained in:
parent
31e3ca1670
commit
6eecef35a6
@ -6,6 +6,7 @@
|
||||
#include <common/arithmeticOverflow.h>
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -205,10 +206,13 @@ inline typename DecimalType::NativeType getFractionalPart(const DecimalType & de
|
||||
return getFractionalPartWithScaleMultiplier(decimal, scaleMultiplier<typename DecimalType::NativeType>(scale));
|
||||
}
|
||||
|
||||
/// Decimal to integer/float conversion
|
||||
/// Decimal to integer/float conversion with the ability to convert into itself (returns the original value);
|
||||
template <typename To, typename DecimalType>
|
||||
To convertTo(const DecimalType & decimal, size_t scale)
|
||||
{
|
||||
if constexpr (std::is_same_v<To, DecimalType>)
|
||||
return decimal;
|
||||
|
||||
using NativeT = typename DecimalType::NativeType;
|
||||
|
||||
if constexpr (std::is_floating_point_v<To>)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <Columns/ColumnFixedString.h>
|
||||
#include <Columns/ColumnConst.h>
|
||||
#include <Columns/ColumnAggregateFunction.h>
|
||||
#include "Core/DecimalFunctions.h"
|
||||
#include "IFunctionImpl.h"
|
||||
#include "FunctionHelpers.h"
|
||||
#include "IsOperation.h"
|
||||
@ -209,7 +210,9 @@ struct DecimalBinaryOperation
|
||||
DivideIntegralImpl<NativeResultType, NativeResultType>, /// substitute divide by intDiv (throw on division by zero)
|
||||
Operation<NativeResultType, NativeResultType>>;
|
||||
|
||||
using ArrayC = typename ColumnDecimal<ResultType>::Container;
|
||||
using ArrayC = typename std::conditional_t<IsDecimalNumber<ResultType>,
|
||||
ColumnDecimal<ResultType>,
|
||||
ColumnVector<ResultType>>::Container;
|
||||
|
||||
template <bool is_decimal_a, bool is_decimal_b, typename ArrayA, typename ArrayB>
|
||||
static void NO_INLINE vectorVector(const ArrayA & a, const ArrayB & b, ArrayC & c,
|
||||
@ -1015,8 +1018,8 @@ public:
|
||||
/// non-vector result
|
||||
if (col_left_const && col_right_const)
|
||||
{
|
||||
const NativeResultType const_a = col_left_const->template getValue<T0>();
|
||||
const NativeResultType const_b = col_right_const->template getValue<T1>();
|
||||
NativeResultType const_a = col_left_const->template getValue<T0>();
|
||||
NativeResultType const_b = col_right_const->template getValue<T1>();
|
||||
|
||||
auto res = check_decimal_overflow ?
|
||||
OpImplCheck::template constantConstant<dec_a, dec_b>(const_a, const_b, scale_a, scale_b) :
|
||||
|
Loading…
Reference in New Issue
Block a user