diff --git a/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h b/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h index db2978db6a0..ca5b1abae8f 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,7 @@ struct SingleValueDataFixed { private: using Self = SingleValueDataFixed; + using ColVecType = std::conditional_t, ColumnDecimal, ColumnVector>; bool has_value = false; /// We need to remember if at least one value has been passed. This is necessary for AggregateFunctionIf. T value; @@ -39,9 +41,9 @@ public: void insertResultInto(IColumn & to) const { if (has()) - assert_cast &>(to).getData().push_back(value); + assert_cast(to).getData().push_back(value); else - assert_cast &>(to).insertDefault(); + assert_cast(to).insertDefault(); } void write(WriteBuffer & buf, const IDataType & /*data_type*/) const @@ -62,7 +64,7 @@ public: void change(const IColumn & column, size_t row_num, Arena *) { has_value = true; - value = assert_cast &>(column).getData()[row_num]; + value = assert_cast(column).getData()[row_num]; } /// Assuming to.has() @@ -113,7 +115,7 @@ public: bool changeIfLess(const IColumn & column, size_t row_num, Arena * arena) { - if (!has() || assert_cast &>(column).getData()[row_num] < value) + if (!has() || assert_cast(column).getData()[row_num] < value) { change(column, row_num, arena); return true; @@ -135,7 +137,7 @@ public: bool changeIfGreater(const IColumn & column, size_t row_num, Arena * arena) { - if (!has() || assert_cast &>(column).getData()[row_num] > value) + if (!has() || assert_cast(column).getData()[row_num] > value) { change(column, row_num, arena); return true; @@ -162,7 +164,7 @@ public: bool isEqualTo(const IColumn & column, size_t row_num) const { - return has() && assert_cast &>(column).getData()[row_num] == value; + return has() && assert_cast(column).getData()[row_num] == value; } }; diff --git a/dbms/src/AggregateFunctions/HelpersMinMaxAny.h b/dbms/src/AggregateFunctions/HelpersMinMaxAny.h index 277af31a6dc..dada68c9791 100644 --- a/dbms/src/AggregateFunctions/HelpersMinMaxAny.h +++ b/dbms/src/AggregateFunctions/HelpersMinMaxAny.h @@ -32,6 +32,12 @@ static IAggregateFunction * createAggregateFunctionSingleValue(const String & na return new AggregateFunctionTemplate>, false>(argument_type); if (which.idx == TypeIndex::DateTime) return new AggregateFunctionTemplate>, false>(argument_type); + if (which.idx == TypeIndex::Decimal32) + return new AggregateFunctionTemplate>, false>(argument_type); + if (which.idx == TypeIndex::Decimal64) + return new AggregateFunctionTemplate>, false>(argument_type); + if (which.idx == TypeIndex::Decimal128) + return new AggregateFunctionTemplate>, false>(argument_type); if (which.idx == TypeIndex::String) return new AggregateFunctionTemplate, true>(argument_type); @@ -54,6 +60,12 @@ static IAggregateFunction * createAggregateFunctionArgMinMaxSecond(const DataTyp return new AggregateFunctionArgMinMax>>, false>(res_type, val_type); if (which.idx == TypeIndex::DateTime) return new AggregateFunctionArgMinMax>>, false>(res_type, val_type); + if (which.idx == TypeIndex::Decimal32) + return new AggregateFunctionArgMinMax>>, false>(res_type, val_type); + if (which.idx == TypeIndex::Decimal64) + return new AggregateFunctionArgMinMax>>, false>(res_type, val_type); + if (which.idx == TypeIndex::Decimal128) + return new AggregateFunctionArgMinMax>>, false>(res_type, val_type); if (which.idx == TypeIndex::String) return new AggregateFunctionArgMinMax>, true>(res_type, val_type); @@ -80,6 +92,12 @@ static IAggregateFunction * createAggregateFunctionArgMinMax(const String & name return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); if (which.idx == TypeIndex::DateTime) return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); + if (which.idx == TypeIndex::Decimal32) + return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); + if (which.idx == TypeIndex::Decimal64) + return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); + if (which.idx == TypeIndex::Decimal128) + return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); if (which.idx == TypeIndex::String) return createAggregateFunctionArgMinMaxSecond(res_type, val_type);