sqlrite 0.1.10__tar.gz → 0.1.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlrite-0.1.10 → sqlrite-0.1.12}/Cargo.lock +5 -5
- {sqlrite-0.1.10 → sqlrite-0.1.12}/Cargo.toml +1 -1
- {sqlrite-0.1.10 → sqlrite-0.1.12}/PKG-INFO +1 -1
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/package.json +1 -1
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/phase-7-plan.md +20 -10
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/roadmap.md +3 -3
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/supported-sql.md +22 -2
- {sqlrite-0.1.10 → sqlrite-0.1.12}/pyproject.toml +1 -1
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/python/Cargo.toml +1 -1
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/executor.rs +673 -20
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/mod.rs +130 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/parser/select.rs +15 -14
- {sqlrite-0.1.10 → sqlrite-0.1.12}/.github/workflows/ci.yml +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/.github/workflows/release-pr.yml +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/.github/workflows/release.yml +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/.github/workflows/rust.yml +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/.gitignore +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/CODE_OF_CONDUCT.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/LICENSE +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/MAINTAINERS +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/Makefile +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/README.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/index.html +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/package-lock.json +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/src/App.svelte +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/src/app.css +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/src/main.ts +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/src/vite-env.d.ts +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/svelte.config.js +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/tsconfig.json +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/desktop/vite.config.ts +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/_index.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/architecture.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/design-decisions.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/desktop.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/embedding.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/file-format.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/getting-started.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/pager.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/release-plan.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/release-secrets.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/smoke-test.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/sql-engine.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/storage-model.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/docs/usage.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/README.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/c/Makefile +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/c/hello.c +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/go/go.mod +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/go/hello.go +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/nodejs/hello.mjs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/python/hello.py +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/rust/quickstart.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/wasm/Makefile +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/examples/wasm/index.html +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/SQLRite - Desktop.png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/SQLRite Data Structures.png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/SQLRite Simple SQL Execution High Level Diagram.png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/SQLRite Simple SQL INSERT Execution High Level Diagram (Insert Row).png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/SQLRite Simple SQL INSERT Execution High Level Diagram.png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/SQLRite_logo.png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/images/architecture.png +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/rust-toolchain.toml +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/AST.delete.example +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/AST.insert.exemple +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/AST.select.example +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/AST.update.example +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/CREATE TABLE sqlrite_schema.sql +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/CREATE_TABLE with duplicate.sql +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/CREATE_TABLE.sql +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/samples/INSERT.sql +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/scripts/bump-version.sh +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/README.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/conn.go +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/go.mod +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/rows.go +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/sqlrite.go +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/sqlrite_test.go +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/go/stmt.go +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/python/README.md +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/python/src/lib.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/sdk/python/tests/test_sqlrite.py +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/connection.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/error.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/lib.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/main.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/meta_command/mod.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/repl/mod.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/db/database.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/db/mod.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/db/secondary_index.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/db/table.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/cell.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/file.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/header.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/index_cell.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/interior_page.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/mod.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/overflow.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/page.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/pager.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/table_page.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/varint.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/pager/wal.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/parser/create.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/parser/insert.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/parser/mod.rs +0 -0
- {sqlrite-0.1.10 → sqlrite-0.1.12}/src/sql/tokenizer.rs +0 -0
|
@@ -3736,7 +3736,7 @@ dependencies = [
|
|
|
3736
3736
|
|
|
3737
3737
|
[[package]]
|
|
3738
3738
|
name = "sqlrite-desktop"
|
|
3739
|
-
version = "0.1.
|
|
3739
|
+
version = "0.1.12"
|
|
3740
3740
|
dependencies = [
|
|
3741
3741
|
"serde",
|
|
3742
3742
|
"serde_json",
|
|
@@ -3748,7 +3748,7 @@ dependencies = [
|
|
|
3748
3748
|
|
|
3749
3749
|
[[package]]
|
|
3750
3750
|
name = "sqlrite-engine"
|
|
3751
|
-
version = "0.1.
|
|
3751
|
+
version = "0.1.12"
|
|
3752
3752
|
dependencies = [
|
|
3753
3753
|
"clap",
|
|
3754
3754
|
"env_logger",
|
|
@@ -3763,7 +3763,7 @@ dependencies = [
|
|
|
3763
3763
|
|
|
3764
3764
|
[[package]]
|
|
3765
3765
|
name = "sqlrite-ffi"
|
|
3766
|
-
version = "0.1.
|
|
3766
|
+
version = "0.1.12"
|
|
3767
3767
|
dependencies = [
|
|
3768
3768
|
"cbindgen",
|
|
3769
3769
|
"sqlrite-engine",
|
|
@@ -3771,7 +3771,7 @@ dependencies = [
|
|
|
3771
3771
|
|
|
3772
3772
|
[[package]]
|
|
3773
3773
|
name = "sqlrite-nodejs"
|
|
3774
|
-
version = "0.1.
|
|
3774
|
+
version = "0.1.12"
|
|
3775
3775
|
dependencies = [
|
|
3776
3776
|
"napi",
|
|
3777
3777
|
"napi-build",
|
|
@@ -3781,7 +3781,7 @@ dependencies = [
|
|
|
3781
3781
|
|
|
3782
3782
|
[[package]]
|
|
3783
3783
|
name = "sqlrite-python"
|
|
3784
|
-
version = "0.1.
|
|
3784
|
+
version = "0.1.12"
|
|
3785
3785
|
dependencies = [
|
|
3786
3786
|
"pyo3",
|
|
3787
3787
|
"sqlrite-engine",
|
|
@@ -27,7 +27,7 @@ resolver = "3"
|
|
|
27
27
|
# `package =` key so the import name stays `sqlrite` internally:
|
|
28
28
|
# sqlrite = { package = "sqlrite-engine", path = "…" }
|
|
29
29
|
name = "sqlrite-engine"
|
|
30
|
-
version = "0.1.
|
|
30
|
+
version = "0.1.12"
|
|
31
31
|
authors = ["Joao Henrique Machado Silva <joaoh82@gmail.com>"]
|
|
32
32
|
edition = "2024"
|
|
33
33
|
rust-version = "1.85"
|
|
@@ -106,24 +106,33 @@ SELECT id, title FROM docs ORDER BY embedding <-> [0.1, ...] LIMIT 10;
|
|
|
106
106
|
- `<=>` → `vec_distance_cosine`
|
|
107
107
|
- `<#>` → `vec_distance_dot`
|
|
108
108
|
|
|
109
|
+
> **Scope correction (2026-04-27, during 7b implementation):** Operators turned out to be a much bigger parser change than Q6 anticipated. sqlparser-rs (current pinned version) **fails outright** on `<->` and `<#>` ("Expected: an expression, found: ->"). Only `<=>` parses, as MySQL's `Spaceship` (null-safe equality). Supporting all three operators requires either a fork of sqlparser to extend the SQLite dialect, or a string-preprocessing pass that rewrites operators to function calls before handing SQL to the parser — neither is the "tiny parser change" Q6 estimated.
|
|
110
|
+
>
|
|
111
|
+
> **Decision:** ship 7b with **functions only**. Operators are deferred to a follow-up sub-phase **7b.1**. The KNN use case (`ORDER BY vec_distance_l2(col, [...]) LIMIT k`) still works — just verbose. When 7b.1 lands, queries can switch from function-call form to operator form without any other behavior change.
|
|
112
|
+
|
|
109
113
|
**Decisions:**
|
|
110
114
|
|
|
111
115
|
- **Dispatch in the existing expression evaluator.** No new function-registration framework — these are built-in functions like `||` is.
|
|
112
|
-
- **Operators land in
|
|
116
|
+
- **Operators land in 7b.1, not 7b.** See scope-correction note above.
|
|
117
|
+
- **`ORDER BY` widened to accept arbitrary expressions** as part of 7b. Pre-7b, the parser restricted ORDER BY to bare column refs; without expression support, KNN queries would have been impossible. New shape: `eval_expr` is called per-row to produce sort keys. This is a strict superset — `ORDER BY col` still works because `Expr::Identifier` takes the same path.
|
|
113
118
|
|
|
114
|
-
**LOC estimate:** ~250 lines.
|
|
119
|
+
**LOC estimate:** ~250 lines for the functions; another ~50 for the ORDER BY parser extension. Total ~300 LOC, slightly over Q-time estimate.
|
|
115
120
|
|
|
116
121
|
**Tests:** all three distance metrics against hand-computed values; operator parsing; KNN result ordering.
|
|
117
122
|
|
|
118
123
|
---
|
|
119
124
|
|
|
120
|
-
### 7c — Brute-force KNN executor optimization
|
|
125
|
+
### ✅ 7c — Brute-force KNN executor optimization
|
|
126
|
+
|
|
127
|
+
**What shipped.** The SELECT executor now branches on `(ORDER BY, LIMIT k)` shape. When both are present and `k < N`, the new `select_topk` function maintains a bounded `BinaryHeap` of size k instead of full-sorting all N rowids. O(N log k) instead of O(N log N).
|
|
128
|
+
|
|
129
|
+
**Implementation note: max-heap with direction-aware Ord.** A single `HeapEntry { key: Value, rowid: i64, asc: bool }` wrapper handles both `ORDER BY ASC LIMIT k` (k smallest) and `ORDER BY DESC LIMIT k` (k largest) without separate code paths. The `asc` flag inverts the natural Ord, so the displacement test reduces to "new entry < heap top" in both cases. After the scan, `into_sorted_vec` returns the right caller-facing order (ascending for ASC, descending for DESC).
|
|
121
130
|
|
|
122
|
-
**
|
|
131
|
+
**Measured speedup** (N=10k, k=10, single REAL column sort key, release build): ~1.8×. The advantage scales with N and with per-row work — KNN queries where the sort key is `vec_distance_l2(col, [...])` benefit much more because each key evaluation is itself O(dim).
|
|
123
132
|
|
|
124
|
-
**
|
|
133
|
+
**LOC**: ~120 implementation + ~180 tests/benchmark = ~300 total. Slightly over the ~150 estimate because the test surface (correctness + bench + edge cases for k=0, k>N, empty input, distance-function integration) ended up larger than initially projected.
|
|
125
134
|
|
|
126
|
-
**
|
|
135
|
+
**Pre-existing bug surfaced.** The seed function for the benchmark needed positive scores because the INSERT parser doesn't currently handle `Expr::UnaryOp(Minus, Number(...))` for negative literals. Worked around with a Knuth-hash scrambler that stays positive; the underlying parser bug is documented as a follow-up.
|
|
127
136
|
|
|
128
137
|
---
|
|
129
138
|
|
|
@@ -296,10 +305,11 @@ let rows = conn.execute(&resp.sql)?;
|
|
|
296
305
|
## Implementation order + dependencies
|
|
297
306
|
|
|
298
307
|
```
|
|
299
|
-
7a (VECTOR type)
|
|
300
|
-
└── 7b (
|
|
301
|
-
└──
|
|
302
|
-
|
|
308
|
+
7a (VECTOR type) — independent, foundational
|
|
309
|
+
└── 7b (distance functions) — needs 7a
|
|
310
|
+
└── 7b.1 (operators) — sugar over 7b; deferred from 7b per scope correction
|
|
311
|
+
└── 7c (KNN exec opt) — needs 7b (operators not required)
|
|
312
|
+
└── 7d (HNSW) — needs 7b/7c
|
|
303
313
|
|
|
304
314
|
7e (JSON) — independent, can interleave anywhere
|
|
305
315
|
|
|
@@ -470,9 +470,9 @@ The full plan + recorded design decisions live in [`docs/phase-7-plan.md`](phase
|
|
|
470
470
|
|
|
471
471
|
Approved sub-phases (Q1–Q10 resolved):
|
|
472
472
|
|
|
473
|
-
-
|
|
474
|
-
-
|
|
475
|
-
-
|
|
473
|
+
- **✅ 7a — `VECTOR(N)` column type** *(v0.1.10)* — dense fixed-dimension f32 storage via the existing cell encoding; format bumped to v4. Bracket-array literal syntax `[0.1, 0.2, …]` (Q7).
|
|
474
|
+
- **✅ 7b — Distance functions** *(v0.1.11)* — `vec_distance_l2/cosine/dot`, plus the ORDER BY-expressions parser change so KNN queries work end-to-end. Operators (`<->` `<=>` `<#>`) deferred to **7b.1** — sqlparser doesn't parse them natively, contradicting Q6's "tiny parser change" assumption.
|
|
475
|
+
- **✅ 7c — Brute-force KNN executor optimization** — bounded `BinaryHeap` of size k for `ORDER BY <expr> LIMIT k`. ~1.8× faster than full-sort at N=10k for cheap keys; bigger gains on expensive keys like `vec_distance_l2`.
|
|
476
476
|
- **7d — HNSW ANN index** — `CREATE INDEX … USING hnsw (col)`; persisted as cell-encoded graph. Fixed defaults `M=16, ef_construction=200, ef_search=50` (Q2).
|
|
477
477
|
- **7e — JSON column type + path queries** — `JSON` data type stored as bincoded `serde_json::Value` (Q3); `json_extract` / `json_array_length` / `json_object_keys` / `json_type`.
|
|
478
478
|
- **7f — ~~Full-text search with BM25~~** — **deferred to Phase 8** (Q1).
|
|
@@ -125,7 +125,7 @@ FROM <table>
|
|
|
125
125
|
|
|
126
126
|
- **Projection**: `*` (all columns in declaration order) or a bare column list. Columns not declared on the table are rejected.
|
|
127
127
|
- **`WHERE`**: any [expression](#expressions). Evaluated per row; NULL-as-false in WHERE context (three-valued logic collapsed to two-valued for filtering).
|
|
128
|
-
- **`ORDER BY`**: single
|
|
128
|
+
- **`ORDER BY`**: single sort key, `ASC` (default) or `DESC`. The sort key can be a bare column reference OR any expression — including function calls — so KNN queries like `ORDER BY vec_distance_l2(embedding, [...]) LIMIT k` work end-to-end *(Phase 7b)*. Sort key types must match; mixing `INTEGER` and `TEXT` across rows under a single `ORDER BY` is a runtime error.
|
|
129
129
|
- **`LIMIT`**: non-negative integer literal. `LIMIT 0` is valid (returns zero rows).
|
|
130
130
|
|
|
131
131
|
### Index probing
|
|
@@ -140,7 +140,7 @@ The executor includes a tiny optimizer: if the `WHERE` is exactly `<indexed_col>
|
|
|
140
140
|
- **`DISTINCT`**
|
|
141
141
|
- **`LIKE`**, **`IN`**, **`IS NULL`** / **`IS NOT NULL`**, `BETWEEN`
|
|
142
142
|
- **Expressions in the projection list** (`SELECT age + 1 FROM users`) — projection is bare column references only
|
|
143
|
-
- **Multi-column `ORDER BY`**, `NULLS FIRST/LAST`
|
|
143
|
+
- **Multi-column `ORDER BY`**, `NULLS FIRST/LAST` (single sort key only; the sort key itself can be an expression as of Phase 7b)
|
|
144
144
|
- **`OFFSET`**
|
|
145
145
|
- **Column aliases** (`SELECT name AS n FROM users`)
|
|
146
146
|
|
|
@@ -196,6 +196,26 @@ Expressions work inside `WHERE` (both in `SELECT`, `UPDATE`, `DELETE`) and on th
|
|
|
196
196
|
|
|
197
197
|
Same set accepted by `INSERT` (see [Value literals accepted](#value-literals-accepted)).
|
|
198
198
|
|
|
199
|
+
### Built-in functions
|
|
200
|
+
|
|
201
|
+
| Function | Returns | Notes |
|
|
202
|
+
|---|---|---|
|
|
203
|
+
| `vec_distance_l2(a, b)` | Real (f64) | Euclidean distance √Σ(aᵢ−bᵢ)². Smaller is closer. *(Phase 7b)* |
|
|
204
|
+
| `vec_distance_cosine(a, b)` | Real (f64) | Cosine distance `1 − (a·b) / (‖a‖·‖b‖)`. Errors on zero-magnitude vectors (cosine is undefined). Smaller is closer; identical vectors return 0.0, orthogonal vectors return 1.0. *(Phase 7b)* |
|
|
205
|
+
| `vec_distance_dot(a, b)` | Real (f64) | Negated dot product `−(a·b)`. Negation makes "smaller is closer" consistent with the others. For unit-norm vectors equals `vec_distance_cosine(a, b) - 1`. *(Phase 7b)* |
|
|
206
|
+
|
|
207
|
+
All three vector-distance functions take exactly two arguments, both of which must be vectors of the same dimension. Either argument can be a column reference (`embedding`), a bracket-array literal (`[0.1, 0.2, 0.3]`), or any sub-expression that evaluates to a vector. Mismatched dimensions error with `vector dimensions don't match (lhs=N, rhs=M)`.
|
|
208
|
+
|
|
209
|
+
The KNN ranking pattern that motivates this set:
|
|
210
|
+
|
|
211
|
+
```sql
|
|
212
|
+
SELECT id, title FROM docs
|
|
213
|
+
ORDER BY vec_distance_l2(embedding, [0.1, 0.2, ..., 0.0])
|
|
214
|
+
LIMIT 10;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> **Operator forms (`<->` `<=>` `<#>`) are not supported yet.** They're the de facto pgvector convention but blocked on a sqlparser limitation — will land as a Phase 7b.1 follow-up. Use the function-call form for now.
|
|
218
|
+
|
|
199
219
|
### Type coercion in arithmetic
|
|
200
220
|
|
|
201
221
|
- **Integer-only ops stay integer.** `1 + 2` → `3` (Integer).
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sqlrite"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.12"
|
|
8
8
|
description = "Python bindings for SQLRite — a small, embeddable SQLite clone written in Rust."
|
|
9
9
|
authors = [{ name = "Joao Henrique Machado Silva", email = "joaoh82@gmail.com" }]
|
|
10
10
|
license = { text = "MIT" }
|