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

[FORMATTING] Spaceship operator (<=>) adding unwanted whitespace #807

Closed
nerixim opened this issue Dec 17, 2024 · 4 comments
Closed

[FORMATTING] Spaceship operator (<=>) adding unwanted whitespace #807

nerixim opened this issue Dec 17, 2024 · 4 comments

Comments

@nerixim
Copy link

nerixim commented Dec 17, 2024

Input data

Which SQL and options did you provide as input?
LangChain function for vector search.

BEGIN RETURN query
SELECT
  documents.id,
  documents.content,
  documents.metadata AS documents_metadata,
  1 - (documents.embedding <=> query_embedding) AS similarity
FROM
  documents
ORDER BY
  documents.embedding <=> query_embedding
LIMIT
  match_count;

END;

Expected Output

BEGIN RETURN query
SELECT
  documents.id,
  documents.content,
  documents.metadata AS documents_metadata,
  1 - (documents.embedding <=> query_embedding) AS similarity
FROM
  documents
ORDER BY
  documents.embedding <=> query_embedding
LIMIT
  match_count;

END;

Actual Output

BEGIN RETURN query
SELECT
  documents.id,
  documents.content,
  documents.metadata AS documents_metadata,
  1 - (documents.embedding <= > query_embedding) AS similarity
FROM
  documents
ORDER BY
  documents.embedding <= > query_embedding
LIMIT
  match_count;

END;

Usage

  • How are you calling / using the library?
    VSCode (yes, I've set the dialect).

  • What SQL language(s) does this apply to?
    Postgres

  • Which SQL Formatter version are you using?
    Extension version 1.6.0

@nerixim nerixim added the bug label Dec 17, 2024
@nene
Copy link
Collaborator

nene commented Dec 17, 2024

First off, please read the FAQ with regards to this specific VSCode extension.

Second, yep, this operator also looks unsupported in the latest version of the library. Thanks for reporting.

@nene
Copy link
Collaborator

nene commented Dec 19, 2024

So, as I understand, this is not a builtin operator in PostgreSQL, but rather a custom one provided by the pgvector extension, among several other operators.

So, this really comes down to the formatter not supporting all possible custom operators in PostgreSQL.

@nene nene closed this as completed in b9cde74 Dec 19, 2024
@nene
Copy link
Collaborator

nene commented Dec 19, 2024

Implemented a support for these specific operators. Though the larger problem with custom operators support remains.

@nene
Copy link
Collaborator

nene commented Dec 19, 2024

Fixed in 15.4.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants