diff --git a/src/AggregateFunctions/AggregateFunctionAvgWeighted.h b/src/AggregateFunctions/AggregateFunctionAvgWeighted.h index f8b452fc444..8b932918aa5 100644 --- a/src/AggregateFunctions/AggregateFunctionAvgWeighted.h +++ b/src/AggregateFunctions/AggregateFunctionAvgWeighted.h @@ -5,18 +5,18 @@ namespace DB { -template +template using AvgWeightedFieldType = std::conditional_t, std::conditional_t, Decimal256, Decimal128>, std::conditional_t, Float64, // no way to do UInt128 * UInt128, better cast to Float64 NearestFieldType>>; -template +template using MaxFieldType = std::conditional_t<(sizeof(AvgWeightedFieldType) > sizeof(AvgWeightedFieldType)), AvgWeightedFieldType, AvgWeightedFieldType>; -template +template class AggregateFunctionAvgWeighted final : public AggregateFunctionAvgBase< MaxFieldType, AvgWeightedFieldType, AggregateFunctionAvgWeighted> diff --git a/src/Core/AccurateComparison.h b/src/Core/AccurateComparison.h index 2099a71cab9..fa32cf518ad 100644 --- a/src/Core/AccurateComparison.h +++ b/src/Core/AccurateComparison.h @@ -21,6 +21,9 @@ using namespace DB; template bool lessOp(A a, B b) { + if constexpr (std::is_same_v) + return a < b; + /// float vs float if constexpr (std::is_floating_point_v && std::is_floating_point_v) return a < b; @@ -94,6 +97,9 @@ bool lessOrEqualsOp(A a, B b) template bool equalsOp(A a, B b) { + if constexpr (std::is_same_v) + return a == b; + /// float vs float if constexpr (std::is_floating_point_v && std::is_floating_point_v) return a == b; @@ -135,9 +141,8 @@ bool equalsOp(A a, B b) return DecomposedFloat(a).equals(b); } - static_assert(is_integer_v || std::is_floating_point_v); - static_assert(is_integer_v || std::is_floating_point_v); - __builtin_unreachable(); + /// e.g comparing UUID with integer. + return false; } template diff --git a/src/Core/TypeListNumber.h b/src/Core/TypeListNumber.h index a6d9b03fff7..b65bdef4e46 100644 --- a/src/Core/TypeListNumber.h +++ b/src/Core/TypeListNumber.h @@ -13,4 +13,6 @@ using TypeListDecimalNumbers = TypeList::Type; using TypeListNumbers = typename TypeListConcat::Type; +using TypeListNumbersAndUUID = typename TypeListConcat>::Type; + } diff --git a/src/DataTypes/NumberTraits.h b/src/DataTypes/NumberTraits.h index ce8ef6d3e91..dc96f2db128 100644 --- a/src/DataTypes/NumberTraits.h +++ b/src/DataTypes/NumberTraits.h @@ -182,11 +182,12 @@ struct ResultOfIf ? max(sizeof(A), sizeof(B)) * 2 : max(sizeof(A), sizeof(B))>::Type; - using ConstructedTypeWithoutUUID = std::conditional_t || std::is_same_v, Error, ConstructedType>; - using ConstructedWithUUID = std::conditional_t && std::is_same_v, A, ConstructedTypeWithoutUUID>; - - using Type = std::conditional_t && !IsDecimalNumber, ConstructedWithUUID, - std::conditional_t && IsDecimalNumber, std::conditional_t<(sizeof(A) > sizeof(B)), A, B>, Error>>; + using Type = + std::conditional_t, A, + std::conditional_t && IsDecimalNumber, + std::conditional_t<(sizeof(A) > sizeof(B)), A, B>, + std::conditional_t && !IsDecimalNumber, + ConstructedType, Error>>>; }; /** Before applying operator `%` and bitwise operations, operands are casted to whole numbers. */ diff --git a/src/Functions/GatherUtils/ArraySinkVisitor.h b/src/Functions/GatherUtils/ArraySinkVisitor.h index 8784191fb0d..7a53da25869 100644 --- a/src/Functions/GatherUtils/ArraySinkVisitor.h +++ b/src/Functions/GatherUtils/ArraySinkVisitor.h @@ -14,7 +14,7 @@ struct GenericArraySink; template struct NullableArraySink; -using NumericArraySinks = typename TypeListMap::Type; +using NumericArraySinks = typename TypeListMap::Type; using BasicArraySinks = typename AppendToTypeList::Type; using NullableArraySinks = typename TypeListMap::Type; using TypeListArraySinks = typename TypeListConcat::Type; diff --git a/src/Functions/GatherUtils/ArraySourceVisitor.h b/src/Functions/GatherUtils/ArraySourceVisitor.h index 9e345d25cd8..1b92a9d2e81 100644 --- a/src/Functions/GatherUtils/ArraySourceVisitor.h +++ b/src/Functions/GatherUtils/ArraySourceVisitor.h @@ -17,7 +17,7 @@ struct NullableArraySource; template struct ConstSource; -using NumericArraySources = typename TypeListMap::Type; +using NumericArraySources = typename TypeListMap::Type; using BasicArraySources = typename AppendToTypeList::Type; class ArraySourceVisitor : public ApplyTypeListForClass::Type diff --git a/src/Functions/GatherUtils/ValueSourceVisitor.h b/src/Functions/GatherUtils/ValueSourceVisitor.h index 2646d6b5ca3..be503cdcfcf 100644 --- a/src/Functions/GatherUtils/ValueSourceVisitor.h +++ b/src/Functions/GatherUtils/ValueSourceVisitor.h @@ -17,7 +17,7 @@ struct NullableValueSource; template struct ConstSource; -using NumericValueSources = typename TypeListMap::Type; +using NumericValueSources = typename TypeListMap::Type; using BasicValueSources = typename AppendToTypeList::Type; using NullableValueSources = typename TypeListMap::Type; using BasicAndNullableValueSources = typename TypeListConcat::Type; diff --git a/src/Functions/GatherUtils/createArraySink.cpp b/src/Functions/GatherUtils/createArraySink.cpp index c0ffe50cbc8..90983c9c25c 100644 --- a/src/Functions/GatherUtils/createArraySink.cpp +++ b/src/Functions/GatherUtils/createArraySink.cpp @@ -55,7 +55,7 @@ struct ArraySinkCreator<> std::unique_ptr createArraySink(ColumnArray & col, size_t column_size) { - using Creator = ApplyTypeListForClass::Type; + using Creator = ApplyTypeListForClass::Type; return Creator::create(col.getData(), col.getOffsets(), column_size); } } diff --git a/src/Functions/GatherUtils/createArraySource.cpp b/src/Functions/GatherUtils/createArraySource.cpp index 3af06f8a8ac..d98a72e456f 100644 --- a/src/Functions/GatherUtils/createArraySource.cpp +++ b/src/Functions/GatherUtils/createArraySource.cpp @@ -58,7 +58,7 @@ struct ArraySourceCreator<> std::unique_ptr createArraySource(const ColumnArray & col, bool is_const, size_t total_rows) { - using Creator = typename ApplyTypeListForClass::Type; + using Creator = typename ApplyTypeListForClass::Type; if (const auto * column_nullable = typeid_cast(&col.getData())) { auto column = ColumnArray::create(column_nullable->getNestedColumnPtr(), col.getOffsetsPtr()); diff --git a/src/Functions/GatherUtils/createValueSource.cpp b/src/Functions/GatherUtils/createValueSource.cpp index 9680c71bfba..4f538b95369 100644 --- a/src/Functions/GatherUtils/createValueSource.cpp +++ b/src/Functions/GatherUtils/createValueSource.cpp @@ -58,7 +58,7 @@ struct ValueSourceCreator<> std::unique_ptr createValueSource(const IColumn & col, bool is_const, size_t total_rows) { - using Creator = typename ApplyTypeListForClass::Type; + using Creator = typename ApplyTypeListForClass::Type; if (const auto * column_nullable = typeid_cast(&col)) { return Creator::create(column_nullable->getNestedColumn(), &column_nullable->getNullMapData(), is_const, total_rows); diff --git a/src/Functions/GregorianDate.h b/src/Functions/GregorianDate.h index 844fb180e5e..06345a1f43a 100644 --- a/src/Functions/GregorianDate.h +++ b/src/Functions/GregorianDate.h @@ -9,6 +9,7 @@ #include + namespace DB { namespace ErrorCodes @@ -27,8 +28,6 @@ namespace DB class GregorianDate { public: - GregorianDate() = delete; - /** Construct from date in text form 'YYYY-MM-DD' by reading from * ReadBuffer. */ diff --git a/src/Functions/if.cpp b/src/Functions/if.cpp index 4883b827d7d..163b642851b 100644 --- a/src/Functions/if.cpp +++ b/src/Functions/if.cpp @@ -986,7 +986,7 @@ public: right_id = right_array->getNestedType()->getTypeId(); if (!(callOnBasicTypes(left_id, right_id, call) - || (res = executeTyped(cond_col, arguments, result_type, input_rows_count)) + || (res = executeTyped(cond_col, arguments, result_type, input_rows_count)) || (res = executeString(cond_col, arguments, result_type)) || (res = executeGenericArray(cond_col, arguments, result_type)) || (res = executeTuple(arguments, result_type, input_rows_count))))