rok commented on a change in pull request #9758:
URL: https://github.com/apache/arrow/pull/9758#discussion_r615834450
##########
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:
How about the case `this->count == options.min_count == 0`?
--
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:
[email protected]