Bug #115846 New vector function DISTANCE introduced in MySQL V9 not found
Submitted: 15 Aug 2024 14:06 Modified: 16 Aug 2024 14:11
Reporter: Richard Lohwasser Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:9.0.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: vector

[15 Aug 2024 14:06] Richard Lohwasser
Description:
The new mysql vector function DISTANCE is not found. Instead, the client returns an error:

ERROR 1305 (42000) at line 1: FUNCTION test.DISTANCE does not exist

The error occurs when using the provided example function usage in the mysql documentation: https://dev.mysql.com/doc/refman/9.0/en/vector-functions.html#function_distance

How to repeat:
1.) Run the latest mysql server:

docker run --rm \
--name mysql-container \
-e MYSQL_ROOT_PASSWORD="" \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=test \
-p 3306:3306 \
mysql:9.0

2.) Run the sql query provided in the mysql documentation:

docker exec -it mysql-container mysql test -e 'SELECT DISTANCE(STRING_TO_VECTOR("[1.01231, 2.0123123, 3.0123123, 4.01231231
]"), STRING_TO_VECTOR("[1, 2, 3, 4]"), "COSINE");'

This returns the error mentioned in the description, instead of the distance of the two vectors as shown in the mysql documentation referenced in the description above.

Suggested fix:
Add function DISTANCE to mysql
[15 Aug 2024 15:35] MySQL Verification Team
Hello Richard Lohwasser,

Thank you for the report and feedback.
For now changing  category to "Documentation" .

regards,
Umesh
[16 Aug 2024 10:28] Richard Lohwasser
Dear Umesh,

thanks for your feedback. Can you give me some background why you categorized the issue as "Documentation"?

If I am just using the function incorrectly and it's just a documentation issue, then that would be great. If so, how should the function be used?

After all, distance calculation is the main use-case for the new vector column introduced as core feature in Mysql 9.
[16 Aug 2024 11:49] MySQL Verification Team
Hello Richard Lohwasser,

Fully agree with you, actually I was unsure of which category to use as DISTANCE/VECTOR_DISTANCE (VECTOR_DISTANCE is a synonym for  DISTANCE) were having issue.  I'll check internally and update the category accordingly. Thank you.

regards,
Umesh
[16 Aug 2024 14:11] Jon Stephens
This function is not included in the Commercial or Community distributions.

Added a note to the function's description in the 9.0 Manual to indicate this.

Closed.