@@ -106,6 +106,60 @@ TEST(NestedProjectionUtilsTest, PruneDataTypeAtomicType) {
106106 ASSERT_TRUE (result.value ()->Equals (data_type));
107107}
108108
109+ TEST (NestedProjectionUtilsTest, PruneDataTypeVector) {
110+ auto data_type = arrow::fixed_size_list (arrow::float32 (), 3 );
111+ auto read_type =
112+ arrow::fixed_size_list (arrow::field (" element" , arrow::float32 (), /* nullable=*/ false ), 3 );
113+ ASSERT_OK_AND_ASSIGN (auto result, NestedProjectionUtils::PruneDataType (read_type, data_type));
114+ ASSERT_TRUE (result.has_value ());
115+ ASSERT_TRUE (result.value ()->Equals (data_type));
116+ }
117+
118+ TEST (NestedProjectionUtilsTest, PruneDataTypeRejectsIncompatibleVectorEvolution) {
119+ auto vector_type = arrow::fixed_size_list (arrow::float32 (), 3 );
120+ std::vector<std::shared_ptr<arrow::DataType>> incompatible_types = {
121+ arrow::fixed_size_list (arrow::float32 (), 5 ),
122+ arrow::fixed_size_list (arrow::float64 (), 3 ),
123+ arrow::list (arrow::float32 ()),
124+ arrow::int32 (),
125+ };
126+ for (const auto & incompatible_type : incompatible_types) {
127+ SCOPED_TRACE (incompatible_type->ToString ());
128+ ASSERT_NOK_WITH_MSG (NestedProjectionUtils::PruneDataType (incompatible_type, vector_type),
129+ " VECTOR type mismatch during schema evolution" );
130+ ASSERT_NOK_WITH_MSG (NestedProjectionUtils::PruneDataType (vector_type, incompatible_type),
131+ " VECTOR type mismatch during schema evolution" );
132+ }
133+ }
134+
135+ TEST (NestedProjectionUtilsTest, PruneDataTypeRejectsNestedVectorEvolution) {
136+ auto data_vector = arrow::fixed_size_list (arrow::float32 (), 3 );
137+ for (const auto & read_vector : {arrow::fixed_size_list (arrow::float32 (), 5 ),
138+ arrow::fixed_size_list (arrow::float64 (), 3 )}) {
139+ SCOPED_TRACE (read_vector->ToString ());
140+ ASSERT_NOK_WITH_MSG (NestedProjectionUtils::PruneDataType (
141+ arrow::struct_ ({MakeField (" embedding" , read_vector, 1 )}),
142+ arrow::struct_ ({MakeField (" embedding" , data_vector, 1 )})),
143+ " VECTOR type mismatch during schema evolution" );
144+ ASSERT_NOK_WITH_MSG (NestedProjectionUtils::PruneDataType (arrow::list (read_vector),
145+ arrow::list (data_vector)),
146+ " VECTOR type mismatch during schema evolution" );
147+ ASSERT_NOK_WITH_MSG (
148+ NestedProjectionUtils::PruneDataType (arrow::map (arrow::utf8 (), read_vector),
149+ arrow::map (arrow::utf8 (), data_vector)),
150+ " VECTOR type mismatch during schema evolution" );
151+ auto read_struct = arrow::struct_ ({MakeField (" embedding" , read_vector, 1 )});
152+ auto data_struct = arrow::struct_ ({MakeField (" embedding" , data_vector, 1 )});
153+ ASSERT_NOK_WITH_MSG (NestedProjectionUtils::PruneDataType (arrow::list (read_struct),
154+ arrow::list (data_struct)),
155+ " VECTOR type mismatch during schema evolution" );
156+ ASSERT_NOK_WITH_MSG (
157+ NestedProjectionUtils::PruneDataType (arrow::map (arrow::utf8 (), read_struct),
158+ arrow::map (arrow::utf8 (), data_struct)),
159+ " VECTOR type mismatch during schema evolution" );
160+ }
161+ }
162+
109163TEST (NestedProjectionUtilsTest, PruneDataTypeStructPruneSubset) {
110164 // data: STRUCT<x:INT(id=1), y:STRING(id=2), z:DOUBLE(id=3)>
111165 // read: STRUCT<x:INT(id=1)>
0 commit comments