@@ -257,6 +257,51 @@ async fn exec_qualified_where_order_by_alias() {
257257 assert_eq ! ( ids[ 0 ] , 1 , "closest alpha row must be row 1\n ids: {ids:?}" ) ;
258258}
259259
260+ // ═══════════════════════════════════════════════════════════════════════════════
261+ // Registration validation
262+ // ═══════════════════════════════════════════════════════════════════════════════
263+
264+ /// Registration must fail when scan_provider schema is missing the key column.
265+ #[ tokio:: test]
266+ async fn reg_scan_provider_missing_key_col_errors ( ) {
267+ // scan_provider schema: only "label" and "vector" — no "id".
268+ let scan_schema = Arc :: new ( Schema :: new ( vec ! [
269+ Field :: new( "label" , DataType :: Utf8 , false ) ,
270+ Field :: new(
271+ "vector" ,
272+ DataType :: FixedSizeList ( Arc :: new( Field :: new( "item" , DataType :: Float32 , true ) ) , 4 ) ,
273+ false ,
274+ ) ,
275+ ] ) ) ;
276+ let scan_provider =
277+ Arc :: new ( HashKeyProvider :: try_new ( scan_schema, vec ! [ ] , "label" ) . expect ( "HashKeyProvider" ) ) ;
278+
279+ // lookup_provider has "id".
280+ let lookup_schema = exec_schema ( ) ;
281+ let lookup_provider =
282+ Arc :: new ( HashKeyProvider :: try_new ( lookup_schema, vec ! [ ] , "id" ) . expect ( "HashKeyProvider" ) ) ;
283+
284+ let reg = USearchRegistry :: new ( ) ;
285+ let result = reg. add (
286+ "test::vector" ,
287+ make_populated_index ( ) ,
288+ scan_provider,
289+ lookup_provider,
290+ "id" ,
291+ MetricKind :: L2sq ,
292+ ScalarKind :: F32 ,
293+ ) ;
294+ assert ! (
295+ result. is_err( ) ,
296+ "registration must fail when scan_provider lacks key column"
297+ ) ;
298+ let msg = result. unwrap_err ( ) . to_string ( ) ;
299+ assert ! (
300+ msg. contains( "scan provider" ) ,
301+ "error must mention scan provider: {msg}"
302+ ) ;
303+ }
304+
260305/// Qualified table, WHERE clause, ORDER BY UDF directly.
261306#[ tokio:: test]
262307async fn exec_qualified_where_order_by_udf ( ) {
0 commit comments