andishgar commented on code in PR #47204:
URL: https://github.com/apache/arrow/pull/47204#discussion_r2311983186
##########
cpp/src/arrow/record_batch_test.cc:
##########
@@ -62,7 +63,49 @@ using util::Float16;
class TestRecordBatch : public ::testing::Test {};
TEST_F(TestRecordBatch, Equals) {
- const int length = 10;
+ int length = 10;
+
+ auto f0 = field("f0", int32());
+ auto f1 = field("f1", uint8());
+ auto f2 = field("f2", int16());
+
+ auto schema0 = schema({f0, f1, f2});
+ auto schema1 = schema({f0, f1, f2});
+ auto schema2 = schema({f0, f1});
+
+ random::RandomArrayGenerator gen(42);
+
+ auto a0 = gen.ArrayOf(int32(), length);
+ auto a1 = gen.ArrayOf(uint8(), length);
+ auto a2 = gen.ArrayOf(int16(), length);
+ auto a3 = a0->Slice(0, length / 2);
+ auto a4 = a1->Slice(0, length / 2);
+ auto a5 = gen.ArrayOf(int32(), length);
+ auto a6 = gen.ArrayOf(uint8(), length);
+
+ auto b0 = RecordBatch::Make(schema0, length, {a0, a1, a2});
+ auto b1 = RecordBatch::Make(schema1, length, {a0, a1, a2});
+ auto b2 = RecordBatch::Make(schema2, length, {a0, a1});
+ auto b3 = RecordBatch::Make(schema2, length, {a3, a4});
+ auto b4 = RecordBatch::Make(schema2, length, {a5, a6});
+
+ // Same Values
+ ASSERT_TRUE(b0->Equals(*b1));
+
+ // Different number of columns
+ ASSERT_FALSE(b0->Equals(*b2));
+
+ // Different number of rows
+ ASSERT_FALSE(b2->Equals(*b3));
+
+ // Different values
+ ASSERT_FALSE(b0->Equals(*b4));
Review Comment:
1- Yes, I should be comparing b2 and b4, not b0 and b4.
2- The comparison of` b2` and `b3` is supposed to check the following code
path (as I mentioned above, I mistakenly set the length of `b3`).
https://github.com/apache/arrow/blob/b5ab8ab6841d9977394bab82ece6dcabee73d234/cpp/src/arrow/record_batch.cc#L361-L362
3-The comparison of b2 and b4 is supposed to check the following path.
https://github.com/apache/arrow/blob/b5ab8ab6841d9977394bab82ece6dcabee73d234/cpp/src/arrow/record_batch.cc#L371-L376
--
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]