mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
If for UUID
This commit is contained in:
parent
3ca2c3acbc
commit
b461542388
@ -5,18 +5,18 @@
|
||||
|
||||
namespace DB
|
||||
{
|
||||
template <class T>
|
||||
template <typename T>
|
||||
using AvgWeightedFieldType = std::conditional_t<IsDecimalNumber<T>,
|
||||
std::conditional_t<std::is_same_v<T, Decimal256>, Decimal256, Decimal128>,
|
||||
std::conditional_t<DecimalOrExtendedInt<T>,
|
||||
Float64, // no way to do UInt128 * UInt128, better cast to Float64
|
||||
NearestFieldType<T>>>;
|
||||
|
||||
template <class T, class U>
|
||||
template <typename T, typename U>
|
||||
using MaxFieldType = std::conditional_t<(sizeof(AvgWeightedFieldType<T>) > sizeof(AvgWeightedFieldType<U>)),
|
||||
AvgWeightedFieldType<T>, AvgWeightedFieldType<U>>;
|
||||
|
||||
template <class Value, class Weight>
|
||||
template <typename Value, typename Weight>
|
||||
class AggregateFunctionAvgWeighted final :
|
||||
public AggregateFunctionAvgBase<
|
||||
MaxFieldType<Value, Weight>, AvgWeightedFieldType<Weight>, AggregateFunctionAvgWeighted<Value, Weight>>
|
||||
|
@ -21,6 +21,9 @@ using namespace DB;
|
||||
template <typename A, typename B>
|
||||
bool lessOp(A a, B b)
|
||||
{
|
||||
if constexpr (std::is_same_v<A, B>)
|
||||
return a < b;
|
||||
|
||||
/// float vs float
|
||||
if constexpr (std::is_floating_point_v<A> && std::is_floating_point_v<B>)
|
||||
return a < b;
|
||||
@ -94,6 +97,9 @@ bool lessOrEqualsOp(A a, B b)
|
||||
template <typename A, typename B>
|
||||
bool equalsOp(A a, B b)
|
||||
{
|
||||
if constexpr (std::is_same_v<A, B>)
|
||||
return a == b;
|
||||
|
||||
/// float vs float
|
||||
if constexpr (std::is_floating_point_v<A> && std::is_floating_point_v<B>)
|
||||
return a == b;
|
||||
@ -135,9 +141,8 @@ bool equalsOp(A a, B b)
|
||||
return DecomposedFloat<A>(a).equals(b);
|
||||
}
|
||||
|
||||
static_assert(is_integer_v<A> || std::is_floating_point_v<A>);
|
||||
static_assert(is_integer_v<B> || std::is_floating_point_v<B>);
|
||||
__builtin_unreachable();
|
||||
/// e.g comparing UUID with integer.
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename A, typename B>
|
||||
|
@ -13,4 +13,6 @@ using TypeListDecimalNumbers = TypeList<Decimal32, Decimal64, Decimal128, Decima
|
||||
using TypeListGeneralNumbers = typename TypeListConcat<TypeListNativeNumbers, TypeListExtendedNumbers>::Type;
|
||||
using TypeListNumbers = typename TypeListConcat<TypeListGeneralNumbers, TypeListDecimalNumbers>::Type;
|
||||
|
||||
using TypeListNumbersAndUUID = typename TypeListConcat<TypeListNumbers, TypeList<UUID>>::Type;
|
||||
|
||||
}
|
||||
|
@ -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<A, UInt128> || std::is_same_v<B, UInt128>, Error, ConstructedType>;
|
||||
using ConstructedWithUUID = std::conditional_t<std::is_same_v<A, UInt128> && std::is_same_v<B, UInt128>, A, ConstructedTypeWithoutUUID>;
|
||||
|
||||
using Type = std::conditional_t<!IsDecimalNumber<A> && !IsDecimalNumber<B>, ConstructedWithUUID,
|
||||
std::conditional_t<IsDecimalNumber<A> && IsDecimalNumber<B>, std::conditional_t<(sizeof(A) > sizeof(B)), A, B>, Error>>;
|
||||
using Type =
|
||||
std::conditional_t<std::is_same_v<A, B>, A,
|
||||
std::conditional_t<IsDecimalNumber<A> && IsDecimalNumber<B>,
|
||||
std::conditional_t<(sizeof(A) > sizeof(B)), A, B>,
|
||||
std::conditional_t<!IsDecimalNumber<A> && !IsDecimalNumber<B>,
|
||||
ConstructedType, Error>>>;
|
||||
};
|
||||
|
||||
/** Before applying operator `%` and bitwise operations, operands are casted to whole numbers. */
|
||||
|
@ -14,7 +14,7 @@ struct GenericArraySink;
|
||||
template <typename ArraySink>
|
||||
struct NullableArraySink;
|
||||
|
||||
using NumericArraySinks = typename TypeListMap<NumericArraySink, TypeListNumbers>::Type;
|
||||
using NumericArraySinks = typename TypeListMap<NumericArraySink, TypeListNumbersAndUUID>::Type;
|
||||
using BasicArraySinks = typename AppendToTypeList<GenericArraySink, NumericArraySinks>::Type;
|
||||
using NullableArraySinks = typename TypeListMap<NullableArraySink, BasicArraySinks>::Type;
|
||||
using TypeListArraySinks = typename TypeListConcat<BasicArraySinks, NullableArraySinks>::Type;
|
||||
|
@ -17,7 +17,7 @@ struct NullableArraySource;
|
||||
template <typename Base>
|
||||
struct ConstSource;
|
||||
|
||||
using NumericArraySources = typename TypeListMap<NumericArraySource, TypeListNumbers>::Type;
|
||||
using NumericArraySources = typename TypeListMap<NumericArraySource, TypeListNumbersAndUUID>::Type;
|
||||
using BasicArraySources = typename AppendToTypeList<GenericArraySource, NumericArraySources>::Type;
|
||||
|
||||
class ArraySourceVisitor : public ApplyTypeListForClass<Visitor, BasicArraySources>::Type
|
||||
|
@ -17,7 +17,7 @@ struct NullableValueSource;
|
||||
template <typename Base>
|
||||
struct ConstSource;
|
||||
|
||||
using NumericValueSources = typename TypeListMap<NumericValueSource, TypeListNumbers>::Type;
|
||||
using NumericValueSources = typename TypeListMap<NumericValueSource, TypeListNumbersAndUUID>::Type;
|
||||
using BasicValueSources = typename AppendToTypeList<GenericValueSource, NumericValueSources>::Type;
|
||||
using NullableValueSources = typename TypeListMap<NullableValueSource, BasicValueSources>::Type;
|
||||
using BasicAndNullableValueSources = typename TypeListConcat<BasicValueSources, NullableValueSources>::Type;
|
||||
|
@ -55,7 +55,7 @@ struct ArraySinkCreator<>
|
||||
|
||||
std::unique_ptr<IArraySink> createArraySink(ColumnArray & col, size_t column_size)
|
||||
{
|
||||
using Creator = ApplyTypeListForClass<ArraySinkCreator, TypeListNumbers>::Type;
|
||||
using Creator = ApplyTypeListForClass<ArraySinkCreator, TypeListNumbersAndUUID>::Type;
|
||||
return Creator::create(col.getData(), col.getOffsets(), column_size);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ struct ArraySourceCreator<>
|
||||
|
||||
std::unique_ptr<IArraySource> createArraySource(const ColumnArray & col, bool is_const, size_t total_rows)
|
||||
{
|
||||
using Creator = typename ApplyTypeListForClass<ArraySourceCreator, TypeListNumbers>::Type;
|
||||
using Creator = typename ApplyTypeListForClass<ArraySourceCreator, TypeListNumbersAndUUID>::Type;
|
||||
if (const auto * column_nullable = typeid_cast<const ColumnNullable *>(&col.getData()))
|
||||
{
|
||||
auto column = ColumnArray::create(column_nullable->getNestedColumnPtr(), col.getOffsetsPtr());
|
||||
|
@ -58,7 +58,7 @@ struct ValueSourceCreator<>
|
||||
|
||||
std::unique_ptr<IValueSource> createValueSource(const IColumn & col, bool is_const, size_t total_rows)
|
||||
{
|
||||
using Creator = typename ApplyTypeListForClass<ValueSourceCreator, TypeListNumbers>::Type;
|
||||
using Creator = typename ApplyTypeListForClass<ValueSourceCreator, TypeListNumbersAndUUID>::Type;
|
||||
if (const auto * column_nullable = typeid_cast<const ColumnNullable *>(&col))
|
||||
{
|
||||
return Creator::create(column_nullable->getNestedColumn(), &column_nullable->getNullMapData(), is_const, total_rows);
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -986,7 +986,7 @@ public:
|
||||
right_id = right_array->getNestedType()->getTypeId();
|
||||
|
||||
if (!(callOnBasicTypes<true, true, true, false>(left_id, right_id, call)
|
||||
|| (res = executeTyped<UInt128, UInt128>(cond_col, arguments, result_type, input_rows_count))
|
||||
|| (res = executeTyped<UUID, UUID>(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))))
|
||||
|
Loading…
Reference in New Issue
Block a user