Architecture
The engine is one Rust crate (timelake) used by the CLI and the Python package. It builds on iceberg-rust’s spec types for metadata and manifests, the Rust object_store crate for I/O, Arrow and Parquet for data, and DataFusion for queries. A separate read-only WebAssembly reader (timelake-wasm, used by @timelake/client) shares the table rules in timelake-format. See the Codebase tour for where each part lives.
Where every part runs
Four places code can run, one bucket underneath, and what crosses the wire. Writers, maintenance, and readers are stateless: everything durable is in object storage.
python --+ PyO3 cli --+ rust --+ v [ timelake core ] writer sort, partition, Parquet + index commit put-if-absent, retry maintain inline, tiered reader DataFusion SQL, pruning, index
$ timelake maintain
full compaction
one sorted file
per partition
retention
snapshot cleanup@timelake/client TypeScript, Zod v [ timelake-wasm ] metadata, pruning, Parquet decode, latest / range / bucket queries
DuckDB iceberg_scan Spark Hadoop catalog PyIceberg static table
s3://your-bucket/lake/ +-- timelake-tables.json ............ table list for HTTPS readers +-- iot/readings/ +-- metadata/ | +-- v42.metadata.json ........... schema, contract, snapshots | +-- version-hint.text ........... newest version, for DuckDB and Spark | +-- snap-*.avro ................. manifest list | +-- *-m.avro .................... manifests: column stats per file | +-- lvi-*.parquet ............... last-value index +-- data/time_day=2026-10-12/ +-- *.parquet ................... sorted by (series, time), ZSTD
A commit is one conditional write of the next vN.metadata.json. Two writers can't both win, so there is no lock service and no database.
On-disk layout
<warehouse>/timelake-tables.json list of tables, for readers that can't list objects
<warehouse>/<namespace>/<table>/
metadata/
v1.metadata.json … vN.metadata.json table metadata, one per commit
version-hint.text "N": the latest version (best-effort pointer)
timelake-head version N in one object, for Timelake's readers (see Head object)
snap-<snapshot-id>-<uuid>.avro manifest lists
<uuid>-{added|merged|deleted}-m.avro manifests
lvi-<snapshot-id>-<uuid>.parquet last-value index of a snapshot
data/
<time>_<chunk>=<label>/<uuid-v7>.parquet e.g. time_day=2026-01-03/…
<uuid-v7>.parquet plain tables (no time column) are not partitionedThis is Iceberg’s Hadoop-catalog convention, which is why DuckDB’s iceberg_scan can open a table directory directly. Tables are Iceberg format version 2. Manifests record the partition as an Avro field, so a time column whose name isn't a valid Avro name gets the partition name Iceberg's Avro encoding gives it: event-time is partitioned as event_x2Dtime_day.
Commit protocol
-
Load the current version (see Head object below). The hint and the head are written after a commit and may lag, so the newest
vN.metadata.jsonis what counts. -
Encode data files, a manifest for them, the last-value index, and a new manifest list, then upload them all at once. A large data file’s earlier parts are uploaded while it is written.
-
Create
vN+1.metadata.jsonwith put-if-absent. If it already exists, another writer won: delete this attempt’s manifests, reload, and retry on top of the new version (up to 10 attempts, with jittered backoff). Data files are reused across retries. A metadata file this Timelake couldn’t load is never written.A conditional write can land and still report a failure: the store client retries a request whose response was lost, and the retry finds the file it just created; a timeout says nothing either way. So after a failed or refused write, the writer reads
vN+1.metadata.jsonback. Its own bytes there mean the commit landed, and it returns as committed. Another writer’s mean it lost, as above. If the file can’t be read, or is still missing after an error (the write may land later), the commit fails with “commit outcome unknown” and deletes nothing it wrote: unreferenced files only take space, deleting referenced ones would break the table. Load the table again to see whether it committed. -
Overwrite
version-hint.textwithN+1and write the new head, in the background. The commit doesn’t wait for them; the CLI and the Python package wait for them before the process exits (timelake::flushin Rust). The WebAssembly writer waits for them before it returns, since a Worker may stop when its request ends.
So a commit waits for two round trips to the store: the uploads, then the conditional write.
Appends carrying a batch id first check whether any retained snapshot already has that id; if so, the append is a no-op and its data files are never uploaded.
The engine and the WebAssembly writer follow one set of rules for all of this, defined once in timelake-format: what goes in the snapshot summary, what happens to the last-value index, which manifests are carried over or rewritten, how a conditional write is judged, and how long to wait before a retry. Each does its own requests around them.
Timelake writes its own commits rather than using iceberg-rust’s transaction API, which only supports fast appends. Three operations exist: append, replace (compaction: remove files, add files with the same rows), and delete (retention: remove files). Once a table has more than eight manifests, an append merges the existing ones into one, so planning a scan stays a few reads however many commits the table has seen.
Head object
Following the Iceberg chain (hint, metadata, manifest list, manifests) takes four requests one after another, and a scan then reads each file’s footer. After each commit, Timelake also writes metadata/timelake-head: the table metadata, the live data files with their column statistics, and, while they fit in timelake.head-inline-bytes (1 MiB), the last-value index and the Parquet footers of the newest files. A cold reader gets all of it in one request.
- A cache, not the commit.
vN.metadata.jsonstays the commit point, so DuckDB, Spark, and PyIceberg see no change. The head is written in the background, and only with a conditional write that never replaces a newer head. - Always checked. A head can be behind for a moment (its write is in flight, or a writer crashed before writing it). On S3, GCS, Azure, and local disk, a cold load lists
metadata/vwhile it reads the head: the listing names the newest version, so a current head is confirmed in the same round trip, and an outdated one is skipped. A reader that already has a version checks only whethervN+1.metadata.jsonexists, while the query is planned, and not at all within the settingversion-check-interval(1 second by default) of its last load or check. That check is a HEAD request, or a LIST of that exact name on Tigris, where a HEAD of a missing key is slow (storage optiontimelake_freshness_check). Plain HTTPS can’t list: it reads the version hint with the head, then checks. - Cost.
timelake_version_lookup=hintreads the version hint instead of listing (one more round trip, no LIST). Every request a commit and a query make, and the trade-off of each option, is in Requests and cost. - Any format. The head’s content is a few properties and named Arrow tables (
metadata,files,columns,last_values). A codec encodes them; the head’s header names the codec, so readers decode any head written by a codec they know. Built in:arrow(Arrow IPC with zstd, the default) andjson. Pick one per table withtimelake.head-format, ornoneto write no head. Other formats (Avro, Vortex, BSON, …) are aHeadCodecregistered withLake::register_head_codec. - Fallback. A table without a head (written by another engine or an older Timelake), or with one in a format the reader doesn’t know, is loaded through the metadata chain, as fast as before. The next Timelake commit writes a head.
So a cold “latest” query takes one round trip and a cold filtered scan two (the head, then the data), against three and six without the head.
Writer
- Align each batch to the table schema by column name, converting types only where no value is lost: dictionary, large and view variants to their base type, any time zone to the table's, timestamps and dates to the same or a finer unit, integers to integers, floats to wider floats, and text to numbers, booleans, dates and timestamps. An integer out of range or text that doesn't parse is an error, not a null. Between integers, floats and decimals otherwise (a float to an integer column, an integer above 2^53 to a double, a double to a float), and to a coarser time unit (nanoseconds to microseconds, a
date64to a date), each value must convert exactly. Other conversions, such as booleans or timestamps to integers, are an error naming the column and both types. - Sort by
(partition, series key…, time), keeping input order for ties, and split by partition. An append larger than 1 GiB is sorted in groups of up to 1 GiB, which are then merged in that order, so no column grows past what one Arrow array holds (2 GiB of strings). - Write each partition (eight at a time) with the codec the table's
write.parquet.compression-codecnames (ZSTD level 3 by default), page-level statistics and page indexes, 1M-row row groups, dictionary encoding (floats fall back to byte-stream-split when a dictionary grows too large), delta encoding for the time column, and the sort order recorded in the file. Files roll over at the target size.
Last-value index
On each append, the newest row of every series in the new data is merged with the previous snapshot’s index (later writes win on equal times) and written as a new Parquet file, referenced from the snapshot summary as timelake.last-value-index. Compaction keeps the index; retention drops series whose newest row is older than the cutoff. An index is only extended if it covers the whole table, so a table whose first rows were written by another engine has no index, and latest-row queries on it scan.
Compaction
Inline (size-tiered). After an append, small files (under ¾ of the target size) in the touched partitions are grouped into size tiers of 4× (under 256 KiB, 256 KiB–1 MiB, 1–4 MiB, …). A run of at least timelake.compact-min-files files of one tier, next to each other in commit order, is merged into one file, which lands in a higher tier. Each row is rewritten about once per tier, so write amplification grows with the logarithm of the data size rather than linearly.
Cold partitions. Once the table holds data newer than a partition's end by timelake.compact-cold-after (1 hour by default, measured on the data's time, not the clock), inline maintenance rewrites that partition whole when it has two small files, whether the append touched it or not: data has moved on, and one sorted, duplicate-free file reads fastest, also for engines that don't remove copies themselves. Backfill into a small cold partition rewrites it again.
Full (maintain). A partition with at least two small files, or any file not in the table’s sort order, is rewritten. If it has an unsorted file or holds less than twice the target size, all its files are rewritten into sorted files; otherwise only runs of small files next to each other in commit order. Rows are merged in commit order and, with dedup on, the last row of each (series key, time) group wins. A merged file keeps the data sequence number of the newest file it replaces, so a file committed later still overrides its rows.
At most 24 files per merge. A merge holds part of each input file in memory, so one merge reads at most 24 files. In the engine, merges of several groups run at once while they read at most 24 files together. A larger group is merged in balanced parts, consecutive in commit order, and the report says more is left (more_to_compact); the next run merges the parts. Both writers plan compaction, retention and expiry with the same rules, so a table compacts to the same files whichever writer runs maintenance. Only the engine refreshes rollups.
Streaming. Every file Timelake writes is already sorted, so compaction merges its input files as streams: it reads a few thousand rows of each at a time, emits rows in order, drops older copies as they meet, and writes row groups as they fill. Memory depends on how many files are merged and their row groups, not on the size of the partition. Where one file's rows come before the next row of every other file, the whole run is taken at once instead of row by row: the run's end is found by probing 1, 2, 4… rows ahead, then searching, and the rows of each output batch are gathered from their files in one pass. Files that each hold every series (5-minute batches) alternate series by series, so most runs are a single row. A file not in the table's sort order (written by another engine) is sorted on its own before the merge.
Snapshot expiry
Snapshots older than timelake.snapshot-retention are expired, keeping at least timelake.min-snapshots and at most timelake.max-snapshots. The current snapshot and any snapshot a branch or tag points at (made by another engine) are never expired. Files reachable only from expired snapshots (data files, manifests, manifest lists, indexes) are deleted, along with metadata files older than the metadata log. What the kept snapshots use is read in full before anything changes: if a manifest list or manifest of a kept snapshot is missing, expiry stops with an error that names it, and deletes nothing. One an expired snapshot used that is already gone (an earlier expiry was interrupted) is skipped. Old metadata files are found by listing metadata/v, not the whole metadata directory. Inline, expiry runs in batches of about 20 snapshots.
Reader
- A DataFusion catalog maps namespaces to schemas and tables to a Timelake table provider.
- Before planning, all referenced tables are loaded concurrently, from their heads when they have one. A check for a newer version still pending runs while the query is planned, and the scan waits for it. Planning prunes files with DataFusion’s
PruningPredicateover the Iceberg lower and upper bounds of each file. - With dedup on, files of one partition whose key bounds overlap may hold the same (series, time). They are pruned only on the key columns, split by a hash of the series so all copies of a row land in the same slice, each slice merged by (series, time, commit order) in parallel, and only the latest write of each key is kept; other files are read as they are.
- Remaining files are spread over scan partitions. Each file’s footer goes into DataFusion’s metadata cache once, from the head when it has it, otherwise read from the store. DataFusion’s Parquet scan does row-group and page pruning.
- An optimizer rule replaces the scan in latest-row query shapes with a scan of the last-value index (see Querying).