github-actions[bot] commented on code in PR #64099:
URL: https://github.com/apache/doris/pull/64099#discussion_r3353123195


##########
be/src/exprs/aggregate/aggregate_function_stddev.h:
##########
@@ -135,12 +144,17 @@ struct PopData : BaseData<T, is_stddev>, Name {
 
 template <PrimitiveType T, typename Name, bool is_stddev>
 struct SampData : BaseData<T, is_stddev>, Name {
+    using ColVecResult = std::conditional_t<is_decimal(T), ColumnDecimal128V2, 
ColumnFloat64>;
     void insert_result_into(IColumn& to) const {
-        auto& col = assert_cast<ColumnFloat64&>(to);
+        auto& col = assert_cast<ColVecResult&>(to);
         if (this->count == 1 || this->count == 0) {
-            col.get_data().push_back(std::numeric_limits<double>::quiet_NaN());
+            col.insert_default();
         } else {

Review Comment:
   This writes `0.0`, not SQL `NULL`, for the common grouped/non-null path. 
`SampData::get_return_type()` is `Float64`, and the null wrapper is only added 
when the input argument is nullable; for `GROUP BY` over a non-null column `to` 
is a plain `ColumnFloat64`, so `ColumnFloat64::insert_default()` appends the 
default double value. The updated regression outputs already show singleton 
groups changing from `NaN` to `0.0` in the `*_agg_phase_1_notnull` cases. 
Sample variance/stddev with fewer than two non-null rows should be `NULL`, so 
this silently corrupts query results for singleton groups and one-row window 
frames. Please make the aggregate result actually nullable/mark the null map 
for `count < 2` instead of inserting the nested column default.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to