L-Store: versioned tables on the wvlet engine
L-Store keeps the wvlet engine's tables in a database folder where every commit is a numbered version. You can read any table as it was at an earlier version, name versions with snapshots, try changes on a branch, and commit writes to several tables at once, after checks, so readers never see half of an update.
Create a database
No setup is needed. create database makes a database in a folder, and use makes it the current one:
create database 'data/mydb' if not exists -- the alias is mydb, the folder's name
use mydb
from 'raw/orders.parquet'
save to orders -- mydb.main.orders, at a new version
from orders
where o_totalprice > 1000
append to big_orders -- the next version
With if not exists, the same script works on every run: it creates the database on the first run and opens it on later ones. Without it, create database fails when the folder already holds a database. To open a database that must already exist, use import database 'data/mydb', which fails when the folder holds none.
The alias defaults to the last part of the path, so 'data/mydb' is mydb and 'archive.duckdb' is archive. Add as <alias> to choose another name, or when that part isn't a plain name such as 2024-sales or sales.v2.
- Each write commits at one database version. A write that conflicts with another writer's change, such as a
deleteafter another session appended to the same table, fails instead of losing rows. - The database has no schemas: every table is in
main, somydb.ordersandmydb.main.ordersname the same table, and afteruse mydbso doordersandmain.orders. drop tableremoves a table from the database but keeps its files, so earlier versions stay readable.
Make it the default
To skip create database and use in every script, set lstore to the folder in the wvlet connector of your profile (~/.wvlet/profiles.json), in place of warehouse:
{
"profiles": [
{
"name": "local",
"type": "wvlet",
"properties": { "lstore": "data/mydb" }
}
]
}
Sessions of this profile then open the database at the start, creating it if the folder is empty, and wvlet build saves its models there, committing them at one version (see Builds).
L-Store databases work in the JVM wvlet CLI, on local folders. The npm package, the native CLI, and the browser playground don't open them yet.
Read earlier versions
The database numbers its commits 1, 2, 3, and so on, across all of its tables. show versions in lists the versions that changed a table, newest first, so the top row is its current version:
show versions in orders
After save to orders, an append to orders, and a delete:
┌─────────┬────────────────────────────┬────────┬───────────┬────────┐
│ version │ time │ change │ row_count │ author │
│ long │ timestamp │ string │ long │ string │
├─────────┼────────────────────────────┼────────┼───────────┼────────┤
│ 3 │ 2026-12-04 23:13:25.408+00 │ update │ 2 │ wvlet │
│ 2 │ 2026-12-04 23:13:25.241+00 │ append │ 3 │ wvlet │
│ 1 │ 2026-12-04 23:13:25.172+00 │ create │ 2 │ wvlet │
├─────────┴────────────────────────────┴────────┴───────────┴────────┤
│ 3 rows │
└────────────────────────────────────────────────────────────────────┘
changesays what the version did to this table:create,append,replace(all rows replaced, assave todoes),update(rows deleted, asdeletedoes),alter(a schema change, asreshapemakes),rename, orproperties.row_countis the table's row count at that version.- History follows the table across a rename. A dropped and re-created name starts a new history, and a clone's history starts at the clone.
Every version stays readable:
from orders at version 120 -- the rows of version 120
In SQL files, write FOR VERSION AS OF:
select * from orders FOR VERSION AS OF 120
To find a version, read the database's own catalog. tables, columns, partitions, partition_stats, partition_sets, partition_set_stats, snapshots, and commits take at version too; catalogs and branches always show the session's current state:
| Table | Lists |
|---|---|
system.commits | Commits: version, author, kind, and time_millis |
system.tables | Tables, with each one's latest version and row_count |
system.columns | Columns of each table |
system.partitions | Data files of each table |
system.partition_stats | Min, max, and null count of each column of each data file |
system.partition_sets | Partition sets: Parquet files that list the data files of a large write |
system.partition_set_stats | Min, max, and null count of each column over each partition set |
system.snapshots | Named snapshots |
system.catalogs | Imported databases, with their path, version, and whether each is current |
system.branches | Branches (also show branches) |
from system.commits
order by version desc
limit 5
Snapshots and clones
A snapshot names a version, so you don't have to remember its number:
create snapshot month_close -- name the current version
from orders at snapshot month_close
A clone is a new table with the rows of a table at some version. No data is copied:
create table orders_test clone orders at version 120
A clone stays in its source table's database.
Branches
A branch is a writable copy of the connector's database that costs nothing to make: it shares the data files and the history up to the version it starts from, and its own commits stay off main. Use it as a sandbox, for example for an agent, and drop it when you are done. Branches aren't merged back.
create branch exp -- from the current branch at its latest version
create branch old at version 120 -- or from an older version
use branch exp -- reads and writes now go to exp
from 'raw/orders.parquet'
save to orders -- main doesn't see this
from orders at branch main -- read main without switching
use branch main
show branches -- name, parent, fork_version, version, current
drop branch exp
- Versions keep counting on a branch: one started at version 120 commits 121, 122, and so on, independent of
main's. drop branchrefusesmain, the branch the session uses, and a branch that other branches start from.from system.tables at branch expreads a branch's catalog.
Commit several tables at once
A transaction { … } block makes all of its writes visible together, at one version of the database:
transaction {
from 'raw/orders.parquet'
save to orders
from orders
group by order_date
agg _.count as n
save to daily_orders
-- an audit: it reads the block's own writes, and a failure publishes nothing
from daily_orders
test _.size should not be 0
}
-
Statements in the block read the database as of the version the block started on, plus the block's own writes. Other sessions see none of them until the block ends.
-
A failed
testor an error discards every write of the block. This is the write-audit-publish pattern: put the checks at the end of the block. -
If another session commits a conflicting change first, for example a
save toof the same table, the block runs again on the new version, up to 3 times, before it reportsCOMMIT_CONFLICT. Anappend toconflicts only with a dropped table. Adeleteor a keyedappend toconflicts with a concurrent append only when the appended files can hold rows it changes, by their column statistics. -
A block writes to one L-Store database, and blocks don't nest.
import database '<path>',create database,use database x(oruse x), andcreate snapshotcan't run inside a block. -
run flowin a block commits thesave toandappend towrites of the flow's stages with the block; see Writing Tables from a Stage.
In SQL files, write BEGIN; … COMMIT;, or end with ROLLBACK; to discard the writes.
Builds commit at one version
wvlet build on an L-Store database commits all the models it builds together, at one version, when the build ends. If a model fails, none of them is published, and readers keep seeing the previous build.
Other databases: import and use
A session can open more L-Store databases by path, each under an alias. import names a database that exists, create database makes a new one, and create database … if not exists does whichever applies:
import database 'data/prod' -- an existing database, as prod
create database 'scratch' as dev -- a new one, named dev
from prod.main.orders as o
join dev.main.labels as l on o.id = l.id
save to dev.main.labeled_orders
use database prod -- prod is now the current database (or just: use prod)
from orders at version 120 -- prod.main.orders as of version 120
The rule: import gives a name, use switches to a name that exists, and versions go only on reads.
import database '<path>' [as x]can be shortened toimport '<path>' [as x].- Name an imported database's tables
<alias>.<table>or<alias>.main.<table>. Afteruse database prod,ordersandmain.ordersnameprod.main.orders.use database <connector catalog>(use database wvletby default) returns to the connector's tables. usetakes an explicit kind:use database prod,use connector c,use schema s,use branch b, oruse device gpu. The short formuse prodworks too.use database nopefails withCATALOG_NOT_FOUNDwhen no database is imported asnope.importandusetake no version. A database has no version of its own: read a table of it at a version withfrom prod.main.orders at version 120.- An alias can't be a connector name of the profile, a device (
gpu,cpu), another catalog (system,tpch,tpcds, the connector's own catalog), or a schema of the connector.importandcreate databasereport an error, and you choose another alias withas.create schemalikewise refuses the name of an imported database. show databases(orshow catalogs) lists the connector's catalog, the imported databases, and the built-intpchandtpcdscatalogs,show schemasthe schemas of the connector's catalog and the imported databases (show schemas in tpchlists the sample data sizes), andshow tables in proda database's tables.show tables in prod.systemlists prod's catalog relations, andshow tables in systemthose of the current database withcatalogsandbranches. Afteruse prod,show tableslists prod's tables.- A write goes to one database: a single statement or
transactionblock never writes to two. Saving to an alias that isn't imported is an error.
Which engine runs what
| Feature | Wvlet engine | DuckDB | Trino | Snowflake |
|---|---|---|---|---|
at version | Yes | No | Compiles to FOR VERSION AS OF | No |
| Snapshots, branches | Yes | No | No | No |
| Clones | Yes | No | No | clone without at version |
transaction { … } | Yes, one version | Compiles to BEGIN TRANSACTION; … COMMIT; | Rejected | Compiles to BEGIN TRANSACTION; … COMMIT; |
import database '<path>' of an L-Store database | Yes | Attaches a DuckDB file instead | Opens on the profile's wvlet engine | Opens on the profile's wvlet engine |
- While Trino or Snowflake is active,
importandcreate databaseopen the database on the profile's wvlet engine (itswvletconnector, or a default one). A query that reads only<alias>.main.<table>runs there, and one that joins those tables with the active connector's tables runs as a federated query. use database, writes, and snapshots of an imported database need the wvlet engine to be the active connector.wvlet runrunstransactionblocks only on the wvlet engine.
File statistics
The database records the min, max, and null count of each column of every data file it writes. A query with a filter reads only the files whose values can match, without opening the others, and explain shows how many it kept (catalog files: 1 of 3). To see the statistics:
from system.partition_stats
where column_name = 'order_date'
Files written before the database kept statistics are always read.
A statement whose data files would take more than 64 KB of catalog rows lists them in a partition set, a Parquet file under partition_sets/ in the database folder, instead of one catalog row per file. The catalog keeps the min and max over each partition set, so a filter skips whole partition sets without reading them. system.partitions lists the data files either way. As a database grows by many small writes, it moves the statistics of older files into Parquet files under partition_sets/, named by a file under root/, so the catalog stays small in memory; this changes no query result and isn't a version.
Limits
- JVM CLI only: the npm package, the native CLI, and the browser playground don't open L-Store databases yet.
- Local folders only, not S3 or https.
- One database per write and per
transactionblock. - Branches aren't merged back into
main.
Next
- Tables and Files: name, save, and change tables, and keep them as Iceberg tables instead.
- Table and File Reference: connector properties.
- Federated Queries: join imported databases with Trino or Snowflake tables.