Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/src/arrow/dataset/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class DatasetFixtureMixin : public ::testing::Test {
std::shared_ptr<RecordBatch> lhs;
ASSERT_OK(expected->ReadNext(&lhs));
EXPECT_NE(lhs, nullptr);
AssertBatchesEqual(*lhs, batch, true);
AssertBatchesEqual(*lhs, batch);
}

/// \brief Ensure that record batches found in reader are equals to the
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/arrow/record_batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,8 @@ bool RecordBatch::Equals(const RecordBatch& other, bool check_metadata) const {
return false;
}

if (check_metadata) {
if (!schema_->Equals(*other.schema(), /*check_metadata=*/true)) {
return false;
}
if (!schema_->Equals(*other.schema(), check_metadata)) {
return false;
}

for (int i = 0; i < num_columns(); ++i) {
Expand Down
6 changes: 6 additions & 0 deletions cpp/src/arrow/record_batch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ TEST_F(TestRecordBatch, Equals) {
auto f0 = field("f0", int32());
auto f1 = field("f1", uint8());
auto f2 = field("f2", int16());
auto f2b = field("f2b", int16());

auto metadata = key_value_metadata({"foo"}, {"bar"});

std::vector<std::shared_ptr<Field>> fields = {f0, f1, f2};
auto schema = ::arrow::schema({f0, f1, f2});
auto schema2 = ::arrow::schema({f0, f1});
auto schema3 = ::arrow::schema({f0, f1, f2}, metadata);
auto schema4 = ::arrow::schema({f0, f1, f2b});

random::RandomArrayGenerator gen(42);

Expand All @@ -65,11 +67,15 @@ TEST_F(TestRecordBatch, Equals) {
auto b2 = RecordBatch::Make(schema3, length, {a0, a1, a2});
auto b3 = RecordBatch::Make(schema2, length, {a0, a1});
auto b4 = RecordBatch::Make(schema, length, {a0, a1, a1});
auto b5 = RecordBatch::Make(schema4, length, {a0, a1, a2});

ASSERT_TRUE(b1->Equals(*b1));
ASSERT_FALSE(b1->Equals(*b3));
ASSERT_FALSE(b1->Equals(*b4));

// Same values and types, but different field names
ASSERT_FALSE(b1->Equals(*b5));

// Different metadata
ASSERT_TRUE(b1->Equals(*b2));
ASSERT_FALSE(b1->Equals(*b2, /*check_metadata=*/true));
Expand Down