mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Remove extra instantiations of classes
This commit is contained in:
parent
557b3e370d
commit
47bed13b42
@ -79,6 +79,30 @@ static inline bool callOnAtLeastOneDecimalType(TypeIndex type_num1, TypeIndex ty
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <template <typename, typename> class Operation, typename Name>
|
||||
ColumnPtr executeDecimal(const ColumnWithTypeAndName & col_left, const ColumnWithTypeAndName & col_right, bool check_decimal_overflow)
|
||||
{
|
||||
TypeIndex left_number = col_left.type->getTypeId();
|
||||
TypeIndex right_number = col_right.type->getTypeId();
|
||||
ColumnPtr res;
|
||||
|
||||
auto call = [&](const auto & types) -> bool
|
||||
{
|
||||
using Types = std::decay_t<decltype(types)>;
|
||||
using LeftDataType = typename Types::LeftType;
|
||||
using RightDataType = typename Types::RightType;
|
||||
|
||||
return (res = DecimalComparison<LeftDataType, RightDataType, Operation>::apply(col_left, col_right, check_decimal_overflow))
|
||||
!= nullptr;
|
||||
};
|
||||
|
||||
if (!callOnAtLeastOneDecimalType<true, false, true, true>(left_number, right_number, call))
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR, "Wrong call for {} with {} and {}", Name::name, col_left.type->getName(), col_right.type->getName());
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -729,29 +753,6 @@ private:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ColumnPtr executeDecimal(const ColumnWithTypeAndName & col_left, const ColumnWithTypeAndName & col_right) const
|
||||
{
|
||||
TypeIndex left_number = col_left.type->getTypeId();
|
||||
TypeIndex right_number = col_right.type->getTypeId();
|
||||
ColumnPtr res;
|
||||
|
||||
auto call = [&](const auto & types) -> bool
|
||||
{
|
||||
using Types = std::decay_t<decltype(types)>;
|
||||
using LeftDataType = typename Types::LeftType;
|
||||
using RightDataType = typename Types::RightType;
|
||||
|
||||
return (res = DecimalComparison<LeftDataType, RightDataType, Op>::apply(col_left, col_right, check_decimal_overflow))
|
||||
!= nullptr;
|
||||
};
|
||||
|
||||
if (!callOnAtLeastOneDecimalType<true, false, true, true>(left_number, right_number, call))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Wrong call for {} with {} and {}",
|
||||
getName(), col_left.type->getName(), col_right.type->getName());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ColumnPtr executeString(const IColumn * c0, const IColumn * c1) const
|
||||
{
|
||||
const ColumnString * c0_string = checkAndGetColumn<ColumnString>(c0);
|
||||
@ -1309,7 +1310,8 @@ public:
|
||||
DataTypePtr common_type = getLeastSupertype(DataTypes{left_type, right_type});
|
||||
ColumnPtr c0_converted = castColumn(col_with_type_and_name_left, common_type);
|
||||
ColumnPtr c1_converted = castColumn(col_with_type_and_name_right, common_type);
|
||||
return executeDecimal({c0_converted, common_type, "left"}, {c1_converted, common_type, "right"});
|
||||
return executeDecimal<Op, Name>(
|
||||
{c0_converted, common_type, "left"}, {c1_converted, common_type, "right"}, check_decimal_overflow);
|
||||
}
|
||||
|
||||
/// Check does another data type is comparable to Decimal, includes Int and Float.
|
||||
@ -1332,7 +1334,7 @@ public:
|
||||
= ColumnsWithTypeAndName{{c0_converted, converted_type, "left"}, {c1_converted, converted_type, "right"}};
|
||||
return executeImpl(new_arguments, result_type, input_rows_count);
|
||||
}
|
||||
return executeDecimal(col_with_type_and_name_left, col_with_type_and_name_right);
|
||||
return executeDecimal<Op, Name>(col_with_type_and_name_left, col_with_type_and_name_right, check_decimal_overflow);
|
||||
}
|
||||
if (date_and_datetime)
|
||||
{
|
||||
@ -1342,7 +1344,8 @@ public:
|
||||
if (!((res = executeNumLeftType<UInt32>(c0_converted.get(), c1_converted.get()))
|
||||
|| (res = executeNumLeftType<UInt64>(c0_converted.get(), c1_converted.get()))
|
||||
|| (res = executeNumLeftType<Int32>(c0_converted.get(), c1_converted.get()))
|
||||
|| (res = executeDecimal({c0_converted, common_type, "left"}, {c1_converted, common_type, "right"}))))
|
||||
|| (res = executeDecimal<Op, Name>(
|
||||
{c0_converted, common_type, "left"}, {c1_converted, common_type, "right"}, check_decimal_overflow))))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Date related common types can only be UInt32/UInt64/Int32/Decimal");
|
||||
return res;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ namespace DB
|
||||
|
||||
using FunctionGreater = FunctionComparison<GreaterOp, NameGreater>;
|
||||
using FunctionEquals = FunctionComparison<EqualsOp, NameEquals>;
|
||||
extern template class FunctionComparison<EqualsOp, NameEquals>;
|
||||
|
||||
REGISTER_FUNCTION(Greater)
|
||||
{
|
||||
|
@ -2,13 +2,14 @@
|
||||
#include <Functions/FunctionsComparison.h>
|
||||
#include <Functions/FunctionsLogical.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
using FunctionGreaterOrEquals = FunctionComparison<GreaterOrEqualsOp, NameGreaterOrEquals>;
|
||||
using FunctionGreater = FunctionComparison<GreaterOp, NameGreater>;
|
||||
extern template class FunctionComparison<GreaterOp, NameGreater>;
|
||||
using FunctionEquals = FunctionComparison<EqualsOp, NameEquals>;
|
||||
extern template class FunctionComparison<EqualsOp, NameEquals>;
|
||||
|
||||
REGISTER_FUNCTION(GreaterOrEquals)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ namespace DB
|
||||
|
||||
using FunctionLess = FunctionComparison<LessOp, NameLess>;
|
||||
using FunctionEquals = FunctionComparison<EqualsOp, NameEquals>;
|
||||
extern template class FunctionComparison<EqualsOp, NameEquals>;
|
||||
|
||||
REGISTER_FUNCTION(Less)
|
||||
{
|
||||
|
@ -8,7 +8,9 @@ namespace DB
|
||||
|
||||
using FunctionLessOrEquals = FunctionComparison<LessOrEqualsOp, NameLessOrEquals>;
|
||||
using FunctionLess = FunctionComparison<LessOp, NameLess>;
|
||||
extern template class FunctionComparison<LessOp, NameLess>;
|
||||
using FunctionEquals = FunctionComparison<EqualsOp, NameEquals>;
|
||||
extern template class FunctionComparison<EqualsOp, NameEquals>;
|
||||
|
||||
REGISTER_FUNCTION(LessOrEquals)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user