Skip to content

Commit

Permalink
fixup VEC_Distance_Cosine
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Sep 14, 2024
1 parent e59ad42 commit 658f587
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mysql-test/main/vector.test
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ select id>0,vec_distance_euclidean(v, x'123456') d from t1 order by d limit 3;
select t1.id as id1, t2.id as id2, vec_distance_euclidean(t1.v, t2.v) from t1, t1 as t2 order by 3,1,2;

# see if order by uses index:
--disable_view_protocol
--disable_ps2_protocol
flush session status;
--replace_regex /(\.\d{5})\d+/\1/
Expand All @@ -69,6 +70,7 @@ flush session status;
select id,vec_distance_cosine(v, x'B047263c9f87233fcfd27e3eae493e3f0329f43e') d from t1 order by d limit 3;
show status like 'handler_read_rnd_next'; # not used, wrong distance metric
--enable_ps2_protocol
--enable_view_protocol

# test delete
delete from t1 where v = x'7b713f3e5258323f80d1113d673b2b3f66e3583f';
Expand Down Expand Up @@ -204,6 +206,7 @@ insert t1 (v) values (x'e360d63ebe554f3fcdbc523f4522193f5236083d'),
--replace_regex /(\.\d{5})\d+/\1/
select id,vec_distance_cosine(v, x'B047263c9f87233fcfd27e3eae493e3f0329f43e') d from t1 order by d limit 3;

--disable_view_protocol
--disable_ps2_protocol
flush session status;
--replace_regex /(\.\d{5})\d+/\1/
Expand All @@ -217,6 +220,7 @@ flush session status;
select id,vec_distance_euclidean(v, x'B047263c9f87233fcfd27e3eae493e3f0329f43e') d from t1 order by d limit 3;
show status like 'handler_read_rnd_next';
--enable_ps2_protocol
--enable_view_protocol
drop table t1;


Expand Down
2 changes: 1 addition & 1 deletion sql/item_vectorfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Item_func_vec_distance_cosine: public Item_func_vec_distance_common
:Item_func_vec_distance_common(thd, a, b) {}
LEX_CSTRING func_name_cstring() const override
{
static LEX_CSTRING name= { STRING_WITH_LEN("VEC_CosDistance") };
static LEX_CSTRING name= { STRING_WITH_LEN("VEC_DISTANCE_COSINE") };
return name;
}
Item *do_get_copy(THD *thd) const override
Expand Down

0 comments on commit 658f587

Please sign in to comment.