Skip to content

Quickstart

This walks through one real session in the linal REPL: a hybrid table with a vector column, an index-accelerated similarity search, and a classical linear algebra call. Every statement below was run against a real build of the engine before being written down here.

Each line is one statement: paste them in one at a time in the REPL, or save them to a .lnl file (one statement per line) and run it with linal run <file>.

Terminal window
linal repl

Scalar columns and a native Vector column, in one dataset:

DATASET docs COLUMNS (id: Int, title: String, embedding: Vector(3))
INSERT INTO docs VALUES (1, "Intro to linear algebra", [0.9, 0.1, 0.0])
INSERT INTO docs VALUES (2, "SQL query optimization", [0.1, 0.9, 0.0])
INSERT INTO docs VALUES (3, "Vector search at scale", [0.8, 0.2, 0.1])

COSINE_SIM works directly in SELECT/WHERE/ORDER BY, no separate vector query language:

SELECT id, title, COSINE_SIM(embedding, [1.0, 0.0, 0.0]) AS score
FROM docs
ORDER BY score DESC
┌──────────┬───────────────────────────┬───────────────┐
│ id (INT) ┆ title (STRING) ┆ score (FLOAT) │
╞══════════╪═══════════════════════════╪═══════════════╡
│ 1 ┆ "Intro to linear algebra" ┆ 0.9938837 │
│ 3 ┆ "Vector search at scale" ┆ 0.9630868 │
│ 2 ┆ "SQL query optimization" ┆ 0.11043153 │
└──────────┴───────────────────────────┴───────────────┘

For top-k retrieval at scale, build a vector index and use SEARCH instead of a full ORDER BY scan:

CREATE VECTOR INDEX ON docs(embedding)
SEARCH docs ON embedding QUERY [1.0, 0.0, 0.0] LIMIT 2 INTO nearest
SELECT id, title FROM nearest

Past ~64 rows, CREATE VECTOR INDEX automatically clusters the column (IVF-style). This tiny example is below that threshold, but the syntax is identical at real scale. See Pipelines & Vector Search for the full picture, including the WHERE embedding ~= [...] shorthand and why SEARCH requires an index while ad hoc COSINE_SIM (step 2 above) doesn’t.

No numpy/scipy round-trip:

MATRIX m = [[4, 7], [2, 6]]
LET det = DETERMINANT m
SHOW det
LET inv = INVERSE m
SHOW inv

SHOW prints the full tensor record, including id, creation time, the operation that produced it, shape, and data:

Tensor ID: bae7e999-...
Source Op: DETERMINANT
Shape: []
Data: [10.0]

Try SOLVE, QR, LU, EIGEN, or SVD the same way. See Vectors & Linear Algebra for the full set.

SAVE DATASET docs
LOAD DATASET docs
SHOW ALL DATASETS

SAVE DATASET writes a real Parquet package (data + schema + stats + lineage) to disk, including which columns are indexed; LOAD DATASET rebuilds those indexes automatically on the way back in.