diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc index 6bb915af6ee1d..6e48d5f5cccff 100644 --- a/cpp/src/arrow/compare.cc +++ b/cpp/src/arrow/compare.cc @@ -751,7 +751,9 @@ class TypeEqualsVisitor { } Status Visit(const ListViewType& left) { - return Status::NotImplemented("list-view type comparison"); + const auto& right = checked_cast(right_); + result_ = left.value_type()->Equals(right.value_type()); + return Status::OK(); } Status Visit(const ExtensionType& left) { diff --git a/cpp/src/arrow/type_test.cc b/cpp/src/arrow/type_test.cc index 4fb9598f936dc..7e0f7158fd6ce 100644 --- a/cpp/src/arrow/type_test.cc +++ b/cpp/src/arrow/type_test.cc @@ -2219,6 +2219,25 @@ TEST(TypesTest, TestRunEndEncodedType) { "run_end_encoded>"); } +TEST(TypesTest, TestListViewType) { + auto int32_expected = std::make_shared(int32()); + auto int32_list_view_type = list_view(int32()); + + ASSERT_EQ(*int32_expected, *int32_list_view_type); + + auto int32_list_view_type_cast = + std::dynamic_pointer_cast(int32_list_view_type); + ASSERT_EQ(*int32_list_view_type_cast->value_type(), *int32()); + + ASSERT_TRUE(int32_list_view_type->field(0)->Equals(Field("values", int32(), true))); + + auto int64_list_view_type = list_view(int64()); + ASSERT_NE(*int32_list_view_type, *int64_list_view_type); + + ASSERT_EQ(int32_list_view_type->ToString(), "list_view"); + ASSERT_EQ(int64_list_view_type->ToString(), "list_view"); +} + #define TEST_PREDICATE(all_types, type_predicate) \ for (auto type : all_types) { \ ASSERT_EQ(type_predicate(type->id()), type_predicate(*type)); \