This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 18ef28f304f081b7735f4bd7e8f7592626a6ac84
Author: wangbo <[email protected]>
AuthorDate: Thu Mar 31 23:00:40 2022 +0800

    [fix] vectorization decimal avg inconsistent (#8746)
---
 be/src/vec/aggregate_functions/aggregate_function_avg.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg.h 
b/be/src/vec/aggregate_functions/aggregate_function_avg.h
index 4aeb7fe..5fd392e 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_avg.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_avg.h
@@ -44,6 +44,14 @@ struct AggregateFunctionAvgData {
             // null is handled in AggregationNode::_get_without_key_result
             return static_cast<ResultT>(sum);
         }
+        // to keep the same result with row vesion; see 
AggregateFunctions::decimalv2_avg_get_value
+        if constexpr (std::is_same_v<ResultT, Decimal128> && std::is_same_v<T, 
Decimal128>) {
+            DecimalV2Value decimal_val_count(count, 0);
+            DecimalV2Value decimal_val_sum(static_cast<Int128>(sum));
+            DecimalV2Value cal_ret = decimal_val_sum / decimal_val_count;
+            Decimal128 ret(cal_ret.value());
+            return ret;
+        }
         return static_cast<ResultT>(sum) / count;
     }
 

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

Reply via email to