diff --git a/Cargo.lock b/Cargo.lock index d0f946405457..99520f8d5a3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11217,9 +11217,9 @@ dependencies = [ [[package]] name = "simsimd" -version = "4.4.0" +version = "6.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc843bc8f12d9c8e6b734a0fe8918fc497b42f6ae0f347dbfdad5b5138ab9b4" +checksum = "be2ad0164e13e58a994d3dd1ff57d44cee87c445708e3acea7ad4f03a47092ce" dependencies = [ "cc", ] diff --git a/src/common/function/Cargo.toml b/src/common/function/Cargo.toml index cb876b352dd9..9a546227e826 100644 --- a/src/common/function/Cargo.toml +++ b/src/common/function/Cargo.toml @@ -41,7 +41,7 @@ s2 = { version = "0.0.12", optional = true } serde.workspace = true serde_json.workspace = true session.workspace = true -simsimd = "4" +simsimd = "6" snafu.workspace = true sql.workspace = true statrs = "0.16" diff --git a/tests/cases/standalone/common/types/vector/vector.result b/tests/cases/standalone/common/types/vector/vector.result index ee9bbf45af25..792d0b6728b6 100644 --- a/tests/cases/standalone/common/types/vector/vector.result +++ b/tests/cases/standalone/common/types/vector/vector.result @@ -31,17 +31,17 @@ SELECT * FROM t; | 1970-01-01 00:00:00.003000 | "[7,8,9]" | +----------------------------+-----------+ -SELECT round(cos_distance(v, '[0.0, 0.0, 0.0]'), 4) FROM t; +SELECT round(cos_distance(v, '[0.0, 0.0, 0.0]'), 2) FROM t; +-----------------------------------------------------------+ -| round(cos_distance(t.v,Utf8("[0.0, 0.0, 0.0]")),Int64(4)) | +| round(cos_distance(t.v,Utf8("[0.0, 0.0, 0.0]")),Int64(2)) | +-----------------------------------------------------------+ | 1.0 | | 1.0 | | 1.0 | +-----------------------------------------------------------+ -SELECT *, round(cos_distance(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; +SELECT *, round(cos_distance(v, '[0.0, 0.0, 0.0]'), 2) as d FROM t ORDER BY d; +-------------------------+--------------------------+-----+ | ts | v | d | @@ -51,30 +51,30 @@ SELECT *, round(cos_distance(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; | 1970-01-01T00:00:00.003 | 0000e0400000004100001041 | 1.0 | +-------------------------+--------------------------+-----+ -SELECT round(cos_distance('[7.0, 8.0, 9.0]', v), 4) FROM t; +SELECT round(cos_distance('[7.0, 8.0, 9.0]', v), 2) FROM t; +-----------------------------------------------------------+ -| round(cos_distance(Utf8("[7.0, 8.0, 9.0]"),t.v),Int64(4)) | +| round(cos_distance(Utf8("[7.0, 8.0, 9.0]"),t.v),Int64(2)) | +-----------------------------------------------------------+ -| 0.0406 | -| 0.0018 | +| 0.04 | +| 0.0 | | 0.0 | +-----------------------------------------------------------+ -SELECT *, round(cos_distance('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; +SELECT *, round(cos_distance('[7.0, 8.0, 9.0]', v), 2) as d FROM t ORDER BY d; -+-------------------------+--------------------------+--------+ -| ts | v | d | -+-------------------------+--------------------------+--------+ -| 1970-01-01T00:00:00.003 | 0000e0400000004100001041 | 0.0 | -| 1970-01-01T00:00:00.002 | 000080400000a0400000c040 | 0.0018 | -| 1970-01-01T00:00:00.001 | 0000803f0000004000004040 | 0.0406 | -+-------------------------+--------------------------+--------+ ++-------------------------+--------------------------+------+ +| ts | v | d | ++-------------------------+--------------------------+------+ +| 1970-01-01T00:00:00.002 | 000080400000a0400000c040 | 0.0 | +| 1970-01-01T00:00:00.003 | 0000e0400000004100001041 | 0.0 | +| 1970-01-01T00:00:00.001 | 0000803f0000004000004040 | 0.04 | ++-------------------------+--------------------------+------+ -SELECT round(cos_distance(v, v), 4) FROM t; +SELECT round(cos_distance(v, v), 2) FROM t; +---------------------------------------+ -| round(cos_distance(t.v,t.v),Int64(4)) | +| round(cos_distance(t.v,t.v),Int64(2)) | +---------------------------------------+ | 0.0 | | 0.0 | @@ -91,17 +91,17 @@ SELECT cos_distance(v, 1.0) FROM t; Error: 3001(EngineExecuteQuery), Invalid argument error: Encountered non UTF-8 data: invalid utf-8 sequence of 1 bytes from index 2 -SELECT round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 4) FROM t; +SELECT round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 2) FROM t; +------------------------------------------------------------+ -| round(l2sq_distance(t.v,Utf8("[0.0, 0.0, 0.0]")),Int64(4)) | +| round(l2sq_distance(t.v,Utf8("[0.0, 0.0, 0.0]")),Int64(2)) | +------------------------------------------------------------+ | 14.0 | | 77.0 | | 194.0 | +------------------------------------------------------------+ -SELECT *, round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; +SELECT *, round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 2) as d FROM t ORDER BY d; +-------------------------+--------------------------+-------+ | ts | v | d | @@ -111,17 +111,17 @@ SELECT *, round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; | 1970-01-01T00:00:00.003 | 0000e0400000004100001041 | 194.0 | +-------------------------+--------------------------+-------+ -SELECT round(l2sq_distance('[7.0, 8.0, 9.0]', v), 4) FROM t; +SELECT round(l2sq_distance('[7.0, 8.0, 9.0]', v), 2) FROM t; +------------------------------------------------------------+ -| round(l2sq_distance(Utf8("[7.0, 8.0, 9.0]"),t.v),Int64(4)) | +| round(l2sq_distance(Utf8("[7.0, 8.0, 9.0]"),t.v),Int64(2)) | +------------------------------------------------------------+ | 108.0 | | 27.0 | | 0.0 | +------------------------------------------------------------+ -SELECT *, round(l2sq_distance('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; +SELECT *, round(l2sq_distance('[7.0, 8.0, 9.0]', v), 2) as d FROM t ORDER BY d; +-------------------------+--------------------------+-------+ | ts | v | d | @@ -131,10 +131,10 @@ SELECT *, round(l2sq_distance('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; | 1970-01-01T00:00:00.001 | 0000803f0000004000004040 | 108.0 | +-------------------------+--------------------------+-------+ -SELECT round(l2sq_distance(v, v), 4) FROM t; +SELECT round(l2sq_distance(v, v), 2) FROM t; +----------------------------------------+ -| round(l2sq_distance(t.v,t.v),Int64(4)) | +| round(l2sq_distance(t.v,t.v),Int64(2)) | +----------------------------------------+ | 0.0 | | 0.0 | @@ -151,17 +151,17 @@ SELECT l2sq_distance(v, 1.0) FROM t; Error: 3001(EngineExecuteQuery), Invalid argument error: Encountered non UTF-8 data: invalid utf-8 sequence of 1 bytes from index 2 -SELECT round(dot_product(v, '[0.0, 0.0, 0.0]'), 4) FROM t; +SELECT round(dot_product(v, '[0.0, 0.0, 0.0]'), 2) FROM t; +----------------------------------------------------------+ -| round(dot_product(t.v,Utf8("[0.0, 0.0, 0.0]")),Int64(4)) | +| round(dot_product(t.v,Utf8("[0.0, 0.0, 0.0]")),Int64(2)) | +----------------------------------------------------------+ | 0.0 | | 0.0 | | 0.0 | +----------------------------------------------------------+ -SELECT *, round(dot_product(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; +SELECT *, round(dot_product(v, '[0.0, 0.0, 0.0]'), 2) as d FROM t ORDER BY d; +-------------------------+--------------------------+-----+ | ts | v | d | @@ -171,17 +171,17 @@ SELECT *, round(dot_product(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; | 1970-01-01T00:00:00.003 | 0000e0400000004100001041 | 0.0 | +-------------------------+--------------------------+-----+ -SELECT round(dot_product('[7.0, 8.0, 9.0]', v), 4) FROM t; +SELECT round(dot_product('[7.0, 8.0, 9.0]', v), 2) FROM t; +----------------------------------------------------------+ -| round(dot_product(Utf8("[7.0, 8.0, 9.0]"),t.v),Int64(4)) | +| round(dot_product(Utf8("[7.0, 8.0, 9.0]"),t.v),Int64(2)) | +----------------------------------------------------------+ | 50.0 | | 122.0 | | 194.0 | +----------------------------------------------------------+ -SELECT *, round(dot_product('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; +SELECT *, round(dot_product('[7.0, 8.0, 9.0]', v), 2) as d FROM t ORDER BY d; +-------------------------+--------------------------+-------+ | ts | v | d | @@ -191,10 +191,10 @@ SELECT *, round(dot_product('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; | 1970-01-01T00:00:00.003 | 0000e0400000004100001041 | 194.0 | +-------------------------+--------------------------+-------+ -SELECT round(dot_product(v, v), 4) FROM t; +SELECT round(dot_product(v, v), 2) FROM t; +--------------------------------------+ -| round(dot_product(t.v,t.v),Int64(4)) | +| round(dot_product(t.v,t.v),Int64(2)) | +--------------------------------------+ | 14.0 | | 77.0 | diff --git a/tests/cases/standalone/common/types/vector/vector.sql b/tests/cases/standalone/common/types/vector/vector.sql index cea3ef406c63..7d483c442175 100644 --- a/tests/cases/standalone/common/types/vector/vector.sql +++ b/tests/cases/standalone/common/types/vector/vector.sql @@ -11,15 +11,15 @@ SELECT * FROM t; -- SQLNESS PROTOCOL POSTGRES SELECT * FROM t; -SELECT round(cos_distance(v, '[0.0, 0.0, 0.0]'), 4) FROM t; +SELECT round(cos_distance(v, '[0.0, 0.0, 0.0]'), 2) FROM t; -SELECT *, round(cos_distance(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; +SELECT *, round(cos_distance(v, '[0.0, 0.0, 0.0]'), 2) as d FROM t ORDER BY d; -SELECT round(cos_distance('[7.0, 8.0, 9.0]', v), 4) FROM t; +SELECT round(cos_distance('[7.0, 8.0, 9.0]', v), 2) FROM t; -SELECT *, round(cos_distance('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; +SELECT *, round(cos_distance('[7.0, 8.0, 9.0]', v), 2) as d FROM t ORDER BY d; -SELECT round(cos_distance(v, v), 4) FROM t; +SELECT round(cos_distance(v, v), 2) FROM t; -- Unexpected dimension -- SELECT cos_distance(v, '[1.0]') FROM t; @@ -27,15 +27,15 @@ SELECT cos_distance(v, '[1.0]') FROM t; -- Invalid type -- SELECT cos_distance(v, 1.0) FROM t; -SELECT round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 4) FROM t; +SELECT round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 2) FROM t; -SELECT *, round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; +SELECT *, round(l2sq_distance(v, '[0.0, 0.0, 0.0]'), 2) as d FROM t ORDER BY d; -SELECT round(l2sq_distance('[7.0, 8.0, 9.0]', v), 4) FROM t; +SELECT round(l2sq_distance('[7.0, 8.0, 9.0]', v), 2) FROM t; -SELECT *, round(l2sq_distance('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; +SELECT *, round(l2sq_distance('[7.0, 8.0, 9.0]', v), 2) as d FROM t ORDER BY d; -SELECT round(l2sq_distance(v, v), 4) FROM t; +SELECT round(l2sq_distance(v, v), 2) FROM t; -- Unexpected dimension -- SELECT l2sq_distance(v, '[1.0]') FROM t; @@ -44,15 +44,15 @@ SELECT l2sq_distance(v, '[1.0]') FROM t; SELECT l2sq_distance(v, 1.0) FROM t; -SELECT round(dot_product(v, '[0.0, 0.0, 0.0]'), 4) FROM t; +SELECT round(dot_product(v, '[0.0, 0.0, 0.0]'), 2) FROM t; -SELECT *, round(dot_product(v, '[0.0, 0.0, 0.0]'), 4) as d FROM t ORDER BY d; +SELECT *, round(dot_product(v, '[0.0, 0.0, 0.0]'), 2) as d FROM t ORDER BY d; -SELECT round(dot_product('[7.0, 8.0, 9.0]', v), 4) FROM t; +SELECT round(dot_product('[7.0, 8.0, 9.0]', v), 2) FROM t; -SELECT *, round(dot_product('[7.0, 8.0, 9.0]', v), 4) as d FROM t ORDER BY d; +SELECT *, round(dot_product('[7.0, 8.0, 9.0]', v), 2) as d FROM t ORDER BY d; -SELECT round(dot_product(v, v), 4) FROM t; +SELECT round(dot_product(v, v), 2) FROM t; -- Unexpected dimension -- SELECT dot_product(v, '[1.0]') FROM t;