CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS test (id SERIAL PRIMARY KEY, name TEXT, vec vector(3));
INSERT INTO test (name, vec) VALUES ('test1', '[1,2,3]');
INSERT INTO test (name, vec) VALUES ('test2', '[4,5,6]');
INSERT INTO test (name, vec) VALUES ('test3', '[7,8,9]');
SELECT name, vec, vec <-> '[3,1,2]' AS distance FROM test;
Expected Output
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS test (id SERIAL PRIMARY KEY, name TEXT, vec vector (3));
INSERT INTO
test (name, vec)
VALUES
('test1', '[1,2,3]');
INSERT INTO
test (name, vec)
VALUES
('test2', '[4,5,6]');
INSERT INTO
test (name, vec)
VALUES
('test3', '[7,8,9]');
SELECT
name,
vec,
vec <-> '[3,1,2]' AS distance
FROM
test;
Actual Output
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS test (id SERIAL PRIMARY KEY, name TEXT, vec vector (3));
INSERT INTO
test (name, vec)
VALUES
('test1', '[1,2,3]');
INSERT INTO
test (name, vec)
VALUES
('test2', '[4,5,6]');
INSERT INTO
test (name, vec)
VALUES
('test3', '[7,8,9]');
SELECT
name,
vec,
vec < - > '[3,1,2]' AS distance
FROM
test;
^ Notice the spaces < - >
I also think it should be vector(3) instead of vector (3) as well
Usage
How are you calling / using the library? format(query)
What SQL language(s) does this apply to? postgres
Which SQL Formatter version are you using? ^15.4.0
Input data
Which SQL and options did you provide as input?
Expected Output
Actual Output
^ Notice the spaces
< - >
I also think it should be
vector(3)
instead ofvector (3)
as wellUsage
format(query)
postgres
^15.4.0