Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
11.8, 12.3, 13.1, 12.3.3
-
None
-
None
-
MariaDB 12.3.3 binary distribution on Debian Linux x86_64
Description
VEC_DISTANCE returns error 4206 when its first argument comes from a user temporary table and its second argument comes from a persistent table with a Euclidean vector index. Reversing the automatic arguments or calling VEC_DISTANCE_EUCLIDEAN explicitly returns the correct distance.
Steps to reproduce
- Save the following as case.sql:
CREATE DATABASE IF NOT EXISTS vector_test; |
USE vector_test; |
CREATE TABLE indexed_vectors ( |
id INT PRIMARY KEY, |
v VECTOR(2) NOT NULL, |
VECTOR INDEX(v) DISTANCE=euclidean |
) ENGINE=InnoDB;
|
INSERT INTO indexed_vectors VALUES (1,VEC_FROMTEXT('[1,2]')); |
|
|
CREATE TEMPORARY TABLE temp_vectors ( |
v VECTOR(2) NOT NULL |
) ENGINE=InnoDB;
|
INSERT INTO temp_vectors VALUES (VEC_FROMTEXT('[4,6]')); |
|
|
DELIMITER //
|
BEGIN NOT ATOMIC |
DECLARE forward_distance DOUBLE DEFAULT NULL; |
DECLARE reverse_distance DOUBLE DEFAULT NULL; |
DECLARE explicit_distance DOUBLE DEFAULT NULL; |
DECLARE error_code INT DEFAULT 0; |
DECLARE error_message TEXT DEFAULT ''; |
|
|
SELECT VEC_DISTANCE_EUCLIDEAN(tmp.v,idx.v),VEC_DISTANCE(idx.v,tmp.v) |
INTO explicit_distance,reverse_distance |
FROM temp_vectors AS tmp CROSS JOIN indexed_vectors AS idx; |
|
|
BEGIN |
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION |
GET DIAGNOSTICS CONDITION 1 error_code=MYSQL_ERRNO,error_message=MESSAGE_TEXT;
|
SELECT VEC_DISTANCE(tmp.v,idx.v) INTO forward_distance |
FROM temp_vectors AS tmp CROSS JOIN indexed_vectors AS idx; |
END; |
|
|
SELECT 'result' AS label,explicit_distance,reverse_distance, |
forward_distance,error_code,error_message;
|
END// |
DELIMITER ;
|
|
|
DROP TEMPORARY TABLE temp_vectors; |
DROP TABLE indexed_vectors; |
DROP DATABASE vector_test; |
- Run it with the MariaDB command-line client:
mariadb < case.sql |
Actual result
The explicit Euclidean call and the reversed automatic call both return 5. The automatic call with the temporary-table vector first returns NULL and reports error 4206:
label explicit_distance reverse_distance forward_distance error_code error_message
|
result 5 5 NULL 4206 Cannot determine distance type for VEC_DISTANCE, index is not found
|
Expected result
The persistent table's vector index supplies the Euclidean metric, so automatic inference should continue to the second argument when the first argument cannot supply eligible index metadata. The forward automatic call should therefore return 5 with no error, just as the reversed automatic call does. The temporary table does not need its own vector index.
This occurs when automatic vector distance inference examines a temporary-table vector first and an indexed persistent-table vector second.
Attachments
Issue Links
- relates to
-
MDEV-35724 VEC_DISTANCE does not work in HAVING clause
-
- Closed
-