aucahuasi commented on a change in pull request #11257:
URL: https://github.com/apache/arrow/pull/11257#discussion_r721512467



##########
File path: cpp/src/arrow/compute/kernels/aggregate_test.cc
##########
@@ -873,6 +874,98 @@ TYPED_TEST(TestRandomNumericCountKernel, RandomArrayCount) 
{
   }
 }
 
+//
+// Count Distinct
+//
+
+class TestCountDistinctKernel : public ::testing::Test {
+ protected:
+  void SetUp() override {
+    only_valid = CountOptions(CountOptions::ONLY_VALID);
+    only_null = CountOptions(CountOptions::ONLY_NULL);
+    all = CountOptions(CountOptions::ALL);
+  }
+
+  Datum Expected(int64_t value) { return 
MakeScalar(static_cast<int64_t>(value)); }
+
+  void Check(Datum input, int64_t expected_all, bool has_nulls = true) {
+    int64_t expected_valid = has_nulls ? expected_all - 1 : expected_all;
+    int64_t expected_null = has_nulls ? 1 : 0;
+    CheckScalar("count_distinct", {input}, Expected(expected_valid), 
&only_valid);
+    CheckScalar("count_distinct", {input}, Expected(expected_null), 
&only_null);
+    CheckScalar("count_distinct", {input}, Expected(expected_all), &all);
+  }
+
+  void Check(const std::shared_ptr<DataType>& type, util::string_view json,
+             int64_t expected_all, bool has_nulls = true) {
+    Check(ArrayFromJSON(type, json), expected_all, has_nulls);
+  }
+
+  CountOptions only_valid;
+  CountOptions only_null;
+  CountOptions all;
+};
+
+TEST_F(TestCountDistinctKernel, AllArrowTypesWithNulls) {

Review comment:
       Failed, with this message. I think I'll need to spend some time to see 
what is the real issue here (it would help to have better messages for the 
output :))
   ```cpp
   Value of: CallFunction("count_distinct", {MakeScalar(true)}, &all)
   Expected: value is equal to 1
     Actual: 1, whose value 1 doesn't match
   [  FAILED  ] TestCountDistinctKernel.ScalarTypesWithNulls (0 ms)
   ```




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


Reply via email to