rok commented on a change in pull request #9758:
URL: https://github.com/apache/arrow/pull/9758#discussion_r615787408



##########
File path: cpp/src/arrow/compute/kernels/aggregate_basic_internal.h
##########
@@ -71,41 +72,51 @@ struct SumImpl : public ScalarAggregator {
 
   void MergeFrom(KernelContext*, KernelState&& src) override {
     const auto& other = checked_cast<const ThisType&>(src);
+    this->length += other.length;
     this->count += other.count;
     this->sum += other.sum;
   }
 
   void Finalize(KernelContext*, Datum* out) override {
-    if (this->count == 0) {
+    if (this->count < options.min_count) {
       out->value = std::make_shared<OutputType>();
     } else {
       out->value = MakeScalar(this->sum);
     }
   }
 
+  size_t length = 0;
   size_t count = 0;
   typename SumType::c_type sum = 0;
+  ScalarAggregateOptions options;
 };
 
 template <typename ArrowType, SimdLevel::type SimdLevel>
 struct MeanImpl : public SumImpl<ArrowType, SimdLevel> {
   void Finalize(KernelContext*, Datum* out) override {
-    if (this->count == 0) {
+    if (this->count == 0 || this->count < options.min_count) {

Review comment:
       Would that distinguish between `this->count == 0` and `this->count == 1`?
   What check would you propose here? I might be overthinking something here :)




-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to