@@ -294,6 +294,41 @@ TEST_P(GlobalIndexTest, TestWriteLuminaIndex) {
294294 ASSERT_TRUE (expected_commit_message->TEST_Equal (*index_commit_msg_impl));
295295}
296296
297+ TEST_P (GlobalIndexTest, TestWriteLuminaIndexWithMismatchedDimension) {
298+ arrow::FieldVector fields = {arrow::field (" f0" , arrow::utf8 ()),
299+ arrow::field (" f1" , arrow::list (arrow::float32 ()))};
300+ auto schema = arrow::schema (fields);
301+ std::map<std::string, std::string> lumina_options = {{" lumina.index.dimension" , " 3" },
302+ {" lumina.index.type" , " bruteforce" },
303+ {" lumina.distance.metric" , " l2" },
304+ {" lumina.encoding.type" , " rawf32" },
305+ {" lumina.search.parallel_number" , " 10" }};
306+
307+ std::map<std::string, std::string> options = {
308+ {Options::MANIFEST_FORMAT , " orc" }, {Options::FILE_FORMAT , file_format_},
309+ {Options::FILE_SYSTEM , " local" }, {Options::ROW_TRACKING_ENABLED , " true" },
310+ {Options::DATA_EVOLUTION_ENABLED , " true" }, {Options::READ_BATCH_SIZE , " 1" }};
311+
312+ CreateTable (/* partition_keys=*/ {}, schema, options);
313+ std::string table_path = PathUtil::JoinPath (dir_->Str (), " foo.db/bar" );
314+
315+ std::vector<std::string> write_cols = schema->field_names ();
316+ auto src_array = arrow::ipc::internal::json::ArrayFromJSON (arrow::struct_ (fields), R"( [
317+ ["a", [0.0, 0.0, 0.0]],
318+ ["b", [0.0, 0.0, 0.0, 0.0]]
319+ ])" )
320+ .ValueOrDie ();
321+
322+ ASSERT_OK_AND_ASSIGN (auto commit_msgs, WriteArray (table_path, write_cols, src_array));
323+ ASSERT_OK (Commit (table_path, commit_msgs));
324+
325+ ASSERT_NOK_WITH_MSG (
326+ WriteIndex (table_path, /* partition_filters=*/ {}, " f1" , " lumina" ,
327+ /* options=*/ lumina_options, Range (0 , 1 )),
328+ " invalid input array in LuminaIndexWriter, length of field array [1] multiplied "
329+ " dimension [3] must match length of field value array [4]" );
330+ }
331+
297332TEST_P (GlobalIndexTest, TestWriteIndex) {
298333 CreateTable ();
299334 std::string table_path = PathUtil::JoinPath (dir_->Str (), " foo.db/bar" );
0 commit comments