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