Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser support for shorthand operators (vector functionality) #34

Open
rolandstirnimann opened this issue May 28, 2024 · 1 comment
Open
Assignees
Labels
23.4 bug Something isn't working

Comments

@rolandstirnimann
Copy link
Collaborator

The parser should support the shorthand operators, introduced with Oracle 23.4 (vector functionality). Currently, the code below leads to parse errors. As a workaround, the classical syntax can be used.

SELECT doc_id, chunk_id, chunk_data
  FROM doc_chunks
 ORDER BY chunk_embedding <-> :query_vector -- shorthand for EUCLIDEAN
 FETCH FIRST 4 ROWS ONLY;
 
SELECT doc_id, chunk_id, chunk_data
  FROM doc_chunks
 ORDER BY chunk_embedding <=> :query_vector -- shorthand for COSINE
 FETCH FIRST 4 ROWS ONLY;

SELECT doc_id, chunk_id, chunk_data
  FROM doc_chunks
 ORDER BY chunk_embedding <#> :query_vector -- SHORTHAND FOR DOT
 FETCH FIRST 4 ROWS ONLY; 

@PhilippSalvisberg
Copy link
Collaborator

Yes, these shorthand operators for distances were introduced in 23.4 and documented in May 2024. Therefore I consider this an enhancement request and not a bug.

Here are the examples using the "classical" syntax (functions instead of operators) that do not cause parse errors in version 5.0.1:

-- alternative for <->
select doc_id, chunk_id, chunk_data
  from doc_chunks
 order by vector_distance(chunk_embedding, :query_vector, euclidean)
fetch first 4 rows only;

-- alternative for <=>
select doc_id, chunk_id, chunk_data
  from doc_chunks
 order by vector_distance(chunk_embedding, :query_vector, cosine)
fetch first 4 rows only;

-- alternative for <#> operator
select doc_id, chunk_id, chunk_data
  from doc_chunks
 order by vector_distance(chunk_embedding, :query_vector, dot)
fetch first 4 rows only;

@PhilippSalvisberg PhilippSalvisberg added the enhancement New feature or request label May 28, 2024
@PhilippSalvisberg PhilippSalvisberg added bug Something isn't working 23.4 and removed enhancement New feature or request labels Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
23.4 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants