2121#include < cmath>
2222#include < cstddef>
2323#include < cstdint>
24+ #include < limits>
2425#include < memory>
25- #include < type_traits>
2626
2727#include " core/assert_cast.h"
2828#include " core/column/column.h"
29- #include " core/column/column_nullable.h"
30- #include " core/data_type/data_type_decimal.h"
3129#include " core/data_type/data_type_number.h"
3230#include " core/types.h"
3331#include " exprs/aggregate/aggregate_function.h"
@@ -38,8 +36,6 @@ class Arena;
3836class BufferReadable ;
3937class BufferWritable ;
4038template <PrimitiveType T>
41- class ColumnDecimal ;
42- template <PrimitiveType T>
4339class ColumnVector ;
4440
4541template <PrimitiveType T, bool is_stddev>
@@ -72,7 +68,7 @@ struct BaseData {
7268 // In MySQL, this will directly result in an error due to exceeding the double range.
7369 // For performance reasons, we are uniformly changing it to nan
7470 if (std::isinf (val)) {
75- return std::nan ( " " );
71+ return std::numeric_limits< double >:: quiet_NaN ( );
7672 }
7773 return val;
7874 };
@@ -126,14 +122,9 @@ struct BaseData {
126122
127123template <PrimitiveType T, typename Name, bool is_stddev>
128124struct PopData : BaseData<T, is_stddev>, Name {
129- using ColVecResult = std::conditional_t <is_decimal(T), ColumnDecimal128V2, ColumnFloat64>;
130125 void insert_result_into (IColumn& to) const {
131- auto & col = assert_cast<ColVecResult&>(to);
132- if constexpr (is_decimal (T)) {
133- col.get_data ().push_back (this ->get_pop_result ().value ());
134- } else {
135- col.get_data ().push_back (this ->get_pop_result ());
136- }
126+ auto & col = assert_cast<ColumnFloat64&>(to);
127+ col.get_data ().push_back (this ->get_pop_result ());
137128 }
138129
139130 static DataTypePtr get_return_type () { return std::make_shared<DataTypeFloat64>(); }
@@ -145,17 +136,12 @@ struct PopData : BaseData<T, is_stddev>, Name {
145136
146137template <PrimitiveType T, typename Name, bool is_stddev>
147138struct SampData : BaseData<T, is_stddev>, Name {
148- using ColVecResult = std::conditional_t <is_decimal(T), ColumnDecimal128V2, ColumnFloat64>;
149139 void insert_result_into (IColumn& to) const {
150- auto & col = assert_cast<ColVecResult &>(to);
140+ auto & col = assert_cast<ColumnFloat64 &>(to);
151141 if (this ->count == 1 || this ->count == 0 ) {
152- col.insert_default ( );
142+ col.get_data (). push_back (std::numeric_limits< double >:: quiet_NaN () );
153143 } else {
154- if constexpr (is_decimal (T)) {
155- col.get_data ().push_back (this ->get_samp_result ().value ());
156- } else {
157- col.get_data ().push_back (this ->get_samp_result ());
158- }
144+ col.get_data ().push_back (this ->get_samp_result ());
159145 }
160146 }
161147
0 commit comments