-
Notifications
You must be signed in to change notification settings - Fork 442
Closed
Labels
Description
Input data
Which SQL and options did you provide as input?
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