From 4a871f7edb007ba737004cdcffa770bd05387376 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 23 Nov 2026 18:16:17 +0100 Subject: [PATCH] GH-12681: [C++] Work around FP rounding issues in quantile tests On some architectures (such as Risc-V) and/or with some optimizations enabled (such as `-fma` on x86), the quantile compute kernel may not output results rigorously equal to those from a textbook quantile computation as used in the tests. Allow for some slight divergence (1 ULP) between the results. --- cpp/src/arrow/compute/kernels/aggregate_test.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/aggregate_test.cc b/cpp/src/arrow/compute/kernels/aggregate_test.cc index 4ef2b2f88a51..289adf5bfb3f 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_test.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_test.cc @@ -3849,10 +3849,9 @@ class TestPrimitiveQuantileKernel : public ::testing::Test { for (int64_t j = 0; j < out_array->length(); ++j) { 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))) - << " Actual Value: " << quantiles[j] << "\n" - << "Expected Value: " << numeric_scalar->value; + // The results may not be rigorously equal to the "naive" results + // on some architecture and/or with some compiler flags (GH-12681). + AssertWithinUlp(quantiles[j], numeric_scalar->value, 1); } } else { AssertTypeEqual(out_array->type(), type_singleton());