vibhatha commented on code in PR #36748:
URL: https://github.com/apache/arrow/pull/36748#discussion_r1273524734
##########
cpp/src/arrow/compute/kernels/aggregate_basic.cc:
##########
@@ -150,6 +157,85 @@ Result<std::unique_ptr<KernelState>>
CountInit(KernelContext*,
return std::make_unique<CountImpl>(static_cast<const
CountOptions&>(*args.options));
}
+// ----------------------------------------------------------------------
+// Distinct implementations
+
+struct DistinctImpl : public ScalarAggregator {
+ Status Consume(KernelContext* ctx, const ExecSpan& batch) override {
+ if (batch[0].is_array()) {
+ const ArraySpan& input = batch[0].array;
+ this->arrays.push_back(input.ToArray());
+ } else {
+ const Scalar& input = *batch[0].scalar;
+ std::shared_ptr<arrow::Array> scalar_array;
+ ARROW_ASSIGN_OR_RAISE(scalar_array,
+ arrow::MakeArrayFromScalar(input, 1,
ctx->memory_pool()));
+ this->arrays.push_back(scalar_array);
+ }
+ return Status::OK();
+ }
Review Comment:
On second thoughts, I think this method would need tweaks for Scalar values
separately. Let me work on this a bit further.
--
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]