From 31d7bd61fd2ed567f711b607230d1629cc68080e Mon Sep 17 00:00:00 2001 From: Yibo Cai Date: Mon, 8 Aug 2022 04:46:18 +0000 Subject: [PATCH 1/2] ARROW-17304: [C++][Compute] Print actual values when compare fails in aggregate test --- cpp/src/arrow/compute/kernels/aggregate_test.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/aggregate_test.cc b/cpp/src/arrow/compute/kernels/aggregate_test.cc index c7909487fb3e6..8d014b6d5ea85 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_test.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_test.cc @@ -2543,7 +2543,9 @@ void CheckModes(const Datum& array, const ModeOptions options, for (int i = 0; i < out_array.length(); ++i) { // equal or nan equal ASSERT_TRUE((expected_modes[i] == out_modes[i]) || - (expected_modes[i] != expected_modes[i] && out_modes[i] != out_modes[i])); + (expected_modes[i] != expected_modes[i] && out_modes[i] != out_modes[i])) + << " Actual Value: " << out_modes[i] << "\n" + << "Expected Value: " << expected_modes[i]; ASSERT_EQ(expected_counts[i], out_counts[i]); } } @@ -2561,7 +2563,7 @@ void CheckModes(const Datum& array, const ModeOptions options, const uint8_t* out_modes = out_array.field(0)->data()->GetValues(1); const int64_t* out_counts = out_array.field(1)->data()->GetValues(1); for (int i = 0; i < out_array.length(); ++i) { - ASSERT_TRUE(expected_modes[i] == bit_util::GetBit(out_modes, i)); + ASSERT_EQ(expected_modes[i], bit_util::GetBit(out_modes, i)); ASSERT_EQ(expected_counts[i], out_counts[i]); } } @@ -3351,7 +3353,9 @@ class TestPrimitiveQuantileKernel : public ::testing::Test { const auto& numeric_scalar = checked_pointer_cast(expected[j][i].scalar()); ASSERT_TRUE((quantiles[j] == numeric_scalar->value) || - (std::isnan(quantiles[j]) && std::isnan(numeric_scalar->value))); + (std::isnan(quantiles[j]) && std::isnan(numeric_scalar->value))) + << " Actual Value: " << quantiles[j] << "\n" + << "Expected Value: " << numeric_scalar->value; } } else { AssertTypeEqual(out_array->type(), type_singleton()); From ab518dba429822e7901ecd4033d107a72037aebe Mon Sep 17 00:00:00 2001 From: Yibo Cai Date: Tue, 9 Aug 2022 04:36:48 +0000 Subject: [PATCH 2/2] Insert ARROW_SCOPED_TRACE() for more context --- cpp/src/arrow/compute/kernels/aggregate_test.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/src/arrow/compute/kernels/aggregate_test.cc b/cpp/src/arrow/compute/kernels/aggregate_test.cc index 8d014b6d5ea85..8f400b2d249a2 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_test.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_test.cc @@ -2532,6 +2532,7 @@ template void CheckModes(const Datum& array, const ModeOptions options, const std::vector& expected_modes, const std::vector& expected_counts) { + ARROW_SCOPED_TRACE("Mode Options: ", options.ToString()); ASSERT_OK_AND_ASSIGN(Datum out, Mode(array, options)); ValidateOutput(out); const StructArray out_array(out.array()); @@ -2554,6 +2555,7 @@ template <> void CheckModes(const Datum& array, const ModeOptions options, const std::vector& expected_modes, const std::vector& expected_counts) { + ARROW_SCOPED_TRACE("Mode Options: ", options.ToString()); ASSERT_OK_AND_ASSIGN(Datum out, Mode(array, options)); ValidateOutput(out); const StructArray out_array(out.array()); @@ -3339,6 +3341,7 @@ class TestPrimitiveQuantileKernel : public ::testing::Test { for (size_t i = 0; i < this->interpolations_.size(); ++i) { options.interpolation = this->interpolations_[i]; + ARROW_SCOPED_TRACE("Quantile Options: ", options.ToString()); ASSERT_OK_AND_ASSIGN(Datum out, Quantile(array, options)); const auto& out_array = out.make_array();