wesm commented on a change in pull request #7555:
URL: https://github.com/apache/arrow/pull/7555#discussion_r452494159
##########
File path: cpp/src/arrow/testing/gtest_util.cc
##########
@@ -389,6 +406,28 @@ void CompareBatch(const RecordBatch& left, const
RecordBatch& right,
}
}
+void ApproxCompareBatch(const RecordBatch& left, const RecordBatch& right,
+ bool compare_metadata) {
+ if (!left.schema()->Equals(*right.schema(), compare_metadata)) {
+ FAIL() << "Left schema: " << left.schema()->ToString(compare_metadata)
+ << "\nRight schema: " << right.schema()->ToString(compare_metadata);
+ }
+ ASSERT_EQ(left.num_columns(), right.num_columns())
+ << left.schema()->ToString() << " result: " <<
right.schema()->ToString();
+ ASSERT_EQ(left.num_rows(), right.num_rows());
+ for (int i = 0; i < left.num_columns(); ++i) {
+ if (!left.column(i)->ApproxEquals(right.column(i))) {
+ std::stringstream ss;
+ ss << "Idx: " << i << " Name: " << left.column_name(i);
+ ss << std::endl << "Left: ";
+ ASSERT_OK(PrettyPrint(*left.column(i), 0, &ss));
+ ss << std::endl << "Right: ";
+ ASSERT_OK(PrettyPrint(*right.column(i), 0, &ss));
+ FAIL() << ss.str();
+ }
+ }
+}
Review comment:
Code duplication between Equals/ApproxEquals functions is a bit of a
nuisance, but this can be cleaned up as a follow up (e.g. with a helper lambda
or something)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]