Uh oh!
There was an error while loading. Please reload this page.
GH-46767: [C++] Enable EqualOptions::use_atol_ for arrow::Array, arrow::Scalar, arrow::RecordBatch, and arrow::ChuckedArray - #46779
Conversation
andishgar
commented
Jun 11, 2025
In this pull request, I initially set the default value of |
andishgar
commented
Jun 16, 2025
@kou I have a question regarding |
kou
commented
Jun 17, 2025
I'm OK with it but I like |
andishgar
commented
Jun 17, 2025
@kou, thank you for your response. I'll open an issue to address this. |
There was a problem hiding this comment.
Pull Request Overview
This PR changes the default behavior of the tolerance-based comparison flag (use_atol) to be opt-in, and propagates that flag through Array, Scalar, RecordBatch, and ChunkedArray equality routines, with updated documentation and tests.
- Change
EqualOptions::use_atol_default tofalseand wire it intoArrayEquals,ArrayRangeEquals,ScalarEquals,RecordBatch::Equals, andChunkedArray::Equals. - Update and add unit tests for floating‐point comparisons to exercise the new
use_atolflag in scalar, array, record batch, and statistics tests. - Revise documentation comments to explain the interplay between exact vs. approximate equality and the
use_atoloption.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/src/arrow/scalar_test.cc | Added TestUseAtol to validate ScalarEquals with and without use_atol |
| cpp/src/arrow/record_batch_test.cc | Updated record‐batch tests to assert Equals with use_atol(true) |
| cpp/src/arrow/record_batch.h | Documented use_atol behavior for RecordBatch::Equals and ApproxEquals |
| cpp/src/arrow/compare.h | Changed default use_atol_ to false and added flags/docs for arrays and scalars |
| cpp/src/arrow/compare.cc | Propagate options.use_atol() into ArrayEquals, ArrayRangeEquals, and ScalarEquals |
| cpp/src/arrow/chunked_array.h | Documented use_atol behavior on ChunkedArray::Equals and ApproxEquals |
| cpp/src/arrow/array/statistics_test.cc | Adjusted statistics tests to use use_atol(true) for tolerance-based equality |
| cpp/src/arrow/array/array_test.cc | Added CheckFloatApproxEqualsWithAtol and test case for floating arrays |
Comments suppressed due to low confidence (3)
cpp/src/arrow/record_batch.h:124
- Split this into two sentences or add a period after
ApproxEquals.to separate the clause, e.g.,... ApproxEquals. Schema comparison is included ...for clarity and correct grammar.
/// using \ref arrow::RecordBatch::ApproxEquals Although, Schema comparison is included,
cpp/src/arrow/chunked_array.h:164
- Add unit tests for
ChunkedArray::EqualsandChunkedArray::ApproxEqualsto verify that the newuse_atolflag correctly toggles exact vs. approximate comparisons on chunked arrays.
/// Setting \ref arrow::EqualOptions::use_atol to true is equivalent to
cpp/src/arrow/compare.h:107
- [nitpick] The
use_atolbehavior is documented separately for each overload; consider centralizing or referencing a single description to reduce duplicated comment blocks and ease future maintenance.
/// Returns true if the arrays are exactly equal
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
andishgar
commented
Jun 18, 2025
@kou Thank you for the review. I’ll look into it |
andishgar
commented
Jun 26, 2025
@kou Thank you for your message. I’ll start applying your suggestions from Saturday. By the way, I deleted my last message since it wasn’t relevant to the discussion. If possible, please consider deleting yours as well. |
kou
commented
Jun 26, 2025
OK. I've deleted it. |
andishgar
commented
Jun 28, 2025
@kou I think the following test is broken: arrow/cpp/src/arrow/chunked_array_test.cc Lines 156 to 183 in ed13ced If the intention is to test this condition, the expression will always evaluate to false. This is because new arrow/cpp/src/arrow/chunked_array.cc Lines 329 to 330 in ed13ced 1-Is my understanding correct? 2- Should I open a separate issue and add a TODO above the test? |
kou
commented
Jun 28, 2025
Hmm. I think no. I think that it's a test for |
andishgar
commented
Jun 29, 2025
Oops, sorry—I just realized there's another overload here that checks whether two |
andishgar
commented
Jun 29, 2025
Currently, |
kou
commented
Jun 30, 2025
Yes. Let's work on it as a separated task. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit f8cd17c. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
Rationale for this change
Enable EqualOptions::use_atol for
arrow::Arrayandarrow::Scalar.What changes are included in this PR?
EqualOptions::use_atol_for the following methods.arrow::ScalarEqualsarrow::ArrayRangeEqualsarrow:: ArrayEqualsAre these changes tested?
Yes, I ran the relevant unit tests.
Are there any user-facing changes?
The default value of
EqualOptions::use_atolis changed to falseThis PR includes breaking changes to public APIs. (If there are any breaking changes to public APIs, please explain which changes are breaking. If not, you can remove this.)