Skip to content
Open
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/compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ bool TypeEquals(const DataType& left, const DataType& right, bool check_metadata
return left_fp == right_fp;
}

// TODO remove check_metadata here?
// Fall back to TypeEqualsVisitor when fingerprints are unavailable.
TypeEqualsVisitor visitor(right, check_metadata);
auto error = VisitTypeInline(left, &visitor);
if (!error.ok()) {
Expand Down
25 changes: 25 additions & 0 deletions cpp/src/arrow/type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,31 @@ TEST(TestNestedType, Equals) {
AssertFieldNotEqual(*u0, *u0_bad);
}

TEST(TestNestedType, FieldMetadataComparisonWithEmptyFingerprints) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be too much. I am fine with removing this test case if anyone thinks so. It's more to demonstrate the case of triggering check_metadata.

// Manual ListType with empty fingerprints to force TypeEqualsVisitor path
class EmptyFingerprintListType : public ListType {
public:
using ListType::ListType;

protected:
std::string ComputeFingerprint() const override { return ""; }
std::string ComputeMetadataFingerprint() const override { return ""; }
};

auto metadata1 = key_value_metadata({{"key", "value1"}});
auto metadata2 = key_value_metadata({{"key", "value2"}});
auto field1 = field("item", int32(), true, metadata1);
auto field2 = field("item", int32(), true, metadata2);
auto list1 = std::make_shared<EmptyFingerprintListType>(field1);
auto list2 = std::make_shared<EmptyFingerprintListType>(field2);

ASSERT_TRUE(list1->fingerprint().empty());
ASSERT_TRUE(list1->metadata_fingerprint().empty());

EXPECT_TRUE(list1->Equals(*list2, /* check_metadata = */ false));
EXPECT_FALSE(list1->Equals(*list2, /* check_metadata = */ true));
}

TEST(TestStructType, Basics) {
auto f0_type = int32();
auto f0 = field("f0", f0_type);
Expand Down
Loading