deltalite
Streaming, partition-level upsert for Delta Lake tables
that replaces delta-rs's SQL MERGE with a bounded-memory merge engine. Memory
is bounded by the size of the incoming batch and a few concurrency knobs —
never by the size of the target table.
delta-rs stays the storage and protocol layer (transaction log, checkpoints, Parquet writing, Add-action statistics, S3 conditional-put commits, conflict resolution). deltalite replaces only the merge execution.
import deltalite
table = deltalite.DeltaLiteTable.open("s3://bucket/my_table")
stats = table.upsert(record_batch, primary_keys=["id"], partition_key="day")
print(f"v{stats.version}: +{stats.rows_inserted} / ~{stats.rows_updated}")
Why
delta-rs MERGE executes a DataFusion hash join whose memory scales with the
scanned target, and it can deadlock under a bounded memory pool
(delta-io/delta-rs#4614).
For a large, slowly-changing table merged against a comparatively small batch —
the typical incremental-sync shape — that means either OOM risk or a hang.
deltalite takes a different route:
- Build a primary-key hash set over the (small) source batch.
- Stream the (large) target one Parquet row group at a time, dropping rows whose key is in the source set.
- Write survivors plus the source rows into new files.
- Commit every touched partition in one atomic Delta commit.
Peak memory is bounded by the source batch and the concurrency knobs, not by
the table. In validation, resident memory stayed flat from 62k- to 1M-row
partitions (~4× below MERGE) at matching write volume, via exact
content-based file selection.
Installation
pip install deltalite
# or
uv add deltalite
Prebuilt cp312-abi3 wheels are published for manylinux (2_28) and musllinux
on x86_64/aarch64, and macOS on arm64/x86_64. A single wheel works on any
CPython 3.12 or newer. No Rust toolchain is needed to install.
Usage
upsert accepts anything with the pyarrow C-stream interface — a
pyarrow.Table, a RecordBatch, or a RecordBatchReader:
import pyarrow as pa
import deltalite
table = deltalite.DeltaLiteTable.open(
"s3://bucket/events",
storage_options={
"AWS_REGION": "us-east-1",
"AWS_ACCESS_KEY_ID": "...",
"AWS_SECRET_ACCESS_KEY": "...",
},
)
batch = pa.table({
"id": [1, 2, 3],
"day": ["2026-01-01", "2026-01-01", "2026-01-02"],
"val": ["a", "b", "c"],
})
stats = table.upsert(
batch,
primary_keys=["id"],
partition_key="day", # omit for an unpartitioned table
commit_metadata={"source": "my-sync"},
)
print(stats)
# UpsertStats(version=42, partitions_touched=2, files_added=2, files_removed=1, ...)
Rows in the batch whose primary key already exists are replaced; new keys
are inserted. Deletes are not expressed through upsert — it is an
insert-or-replace by key. Duplicate primary keys within a single batch are
rejected (raising DeltaLiteError) rather than silently double-inserted.
API
DeltaLiteTable
| Method | Description |
|---|---|
DeltaLiteTable.open(uri, storage_options=None) |
Open an existing Delta table. storage_options is the usual object-store dict (S3/GCS/Azure/local). |
DeltaLiteTable.is_deltatable(uri, storage_options=None) |
True if a Delta table exists at uri. |
.upsert(data, primary_keys, partition_key=None, **opts) |
Insert-or-replace data by key. Returns UpsertStats. See knobs below. |
.version() |
Current table version (int). |
.reload() |
Bring the table state up to date with the log (incremental; falls back to a full re-open). |
.table_id() |
The table id from the metadata action (str). |
.configuration() |
Table configuration, delta.* properties and custom keys (dict[str, str]). |
.schema_arrow() |
Table schema as a pyarrow Schema. |
.schema_json() |
Table schema as the Delta JSON document (str), as DeltaTable.schema().to_json() returns it. |
.partition_columns() |
Partition column names (list[str]). |
.num_files() |
Number of active data files (int). |
.files() |
Active data files as dicts: path (relative to the table root), size, modification_time (epoch ms), partition_values (dict[str, str | None]). |
.file_uris() |
URIs of the table's active data files. |
.history(limit) |
Recent commit history entries. |
version, table_id, configuration, schema_*, partition_columns,
num_files, files and file_uris read the loaded snapshot in memory and do
no I/O; call reload() first when the table may have moved. history reads the
log.
UpsertStats
Returned by upsert. Counts: version, partitions_touched, files_added,
files_removed, files_carried_over, files_probed, rows_updated,
rows_inserted, rows_copied, source_rows, null_pk_rows. Per-phase
wall-clock timings (milliseconds): ingest_ms (importing the pyarrow source),
initial_open_ms (the full snapshot load in DeltaLiteTable.open, reported on
the first upsert through a handle and 0 afterwards, so a sum over a handle's
upserts counts it once), open_ms (snapshot refreshes around the upsert),
relax_ms (nullability-relax check), plan_ms (listing + pruning files),
rewrite_ms (reading + rewriting the touched partitions), commit_ms
(committing to the Delta log), maintenance_ms (checkpoint/log cleanup,
non-zero only on checkpoint-boundary commits). columns_relaxed counts
non-nullable columns flipped to nullable before the write.
Exceptions
All inherit from DeltaLiteError, so you can catch the base or branch on kind:
| Exception | Raised when |
|---|---|
DeltaLiteError |
Base class / generic failure. |
DeltaLiteCommitConflictError |
Concurrent commit won the conditional-put race (retry-exhausted). |
DeltaLiteSchemaMismatchError |
Batch schema is incompatible with the table. |
DeltaLiteTableNotFoundError |
No Delta table at the URI. |
DeltaLiteUnsupportedTableError |
Table uses a feature deltalite can't handle (e.g. deletion vectors, column mapping). |
DeltaLiteSourceTooLargeError |
Batch exceeds max_source_bytes (see below). |
Operational knobs
Per-call — keyword arguments to upsert (defaults in parentheses):
| Argument | Default | Purpose |
|---|---|---|
max_parallel_partitions |
2 |
Partitions merged concurrently. |
max_parallel_files |
4 |
Files read concurrently within a partition. |
max_buffered_bytes |
64 MiB |
Output buffered in memory before flushing. |
prune_strategy |
"probe" |
"probe" skips files that can't contain a source key; "none" scans all. |
skip_unmatched_files |
True |
Convenience toggle: False ≡ prune_strategy="none". |
probe_concurrency |
8 |
Concurrent statistics/probe reads. |
read_batch_size |
8192 |
Row-group read batch size. |
target_file_size |
table setting, else 100 MiB | Output file size target. |
max_source_bytes |
2 GiB |
Oversized-batch guard (0 disables). |
multipart_threshold / multipart_part_size |
64 MiB / 16 MiB |
Multipart upload thresholds (0 threshold disables). |
commit_max_retries |
15 |
Conditional-put commit retry budget. |
commit_metadata |
None |
Extra key/values recorded in the Delta commit. |
Process-global — environment variables, enforced on top of the per-call knobs so that many concurrent upsert threads in one process cannot multiply the budgets:
DELTALITE_PROCESS_MAX_PARALLEL_PARTITIONS (8),
DELTALITE_PROCESS_MAX_PARALLEL_FILES (16),
DELTALITE_PROCESS_MAX_BUFFERED_BYTES (256 MiB),
DELTALITE_MAX_SOURCE_BYTES, DELTALITE_MULTIPART_THRESHOLD_BYTES,
DELTALITE_MULTIPART_PART_SIZE_BYTES.
Checkpoint prefetch. Opening or reloading a table reads its latest
checkpoint Parquet file whole in one GET and serves the Parquet reader's many
small range reads from memory, instead of one round trip per footer, metadata
block and column chunk. DELTALITE_CHECKPOINT_PREFETCH_MAX_BYTES (128 MiB)
bounds the total checkpoint bytes cached by one table load; larger files or
multipart checkpoints that exhaust the budget fall back to range reads, and 0
disables the prefetch. Cached bytes also reserve space from
DELTALITE_PROCESS_MAX_BUFFERED_BYTES, so concurrent table opens share the
process-wide budget. The bytes are released as soon as the load finishes.
Commit snapshot adoption. After a successful upsert the handle keeps the
table state delta-rs derived for the commit it just wrote (the same state every
delta-rs operation returns) instead of listing the log and reading that commit
back. The next upsert still refreshes before it plans, so commits from other
writers are observed exactly as before, and a checkpoint the upsert's own
maintenance wrote is adopted on that refresh.
DELTALITE_ADOPT_COMMIT_SNAPSHOT=0 restores the post-commit refresh.
Data-file reads. Every Parquet data file is opened with a 64 KiB footer size hint, so a footer that fits arrives in one GET instead of two, and a file the probe found a match in hands its parsed footer to the rewrite, so the file is not opened a second time.
Metrics
deltalite emits via the Rust metrics facade (static
labels only): deltalite_upserts_total (outcome, prune_strategy,
error_kind), deltalite_upsert_duration_seconds,
deltalite_files_{added,removed,carried_over,probed}_total,
deltalite_rows_{updated,inserted,copied}_total, and
deltalite_checkpoint_prefetch_total (outcome).
Compatibility & status
- Built against
deltalake(delta-rs)0.32.xas the storage/protocol layer. Correctness is guaranteed by a differential parity suite that runs the same batch sequences through real delta-rsMERGEand throughdeltalite.upsertand asserts identical logical content — not by version equality. - Not supported: tables with deletion vectors or column mapping (detected
and raised as
DeltaLiteUnsupportedTableError), and SCD2 merges. - deltalite rejects duplicate source primary keys that
MERGEsilently double-inserts — check pre-existing data if you migrate an existing pipeline.
This package is developed in the PostHog monorepo
under rust/deltalite/. Issues and source live there.
Metadata
Release files for deltalite 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deltalite-0.1.9.tar.gz | 219.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| deltalite-0.1.9-cp312-abi3-musllinux_1_2_x86_64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ x86-64 | Details |
| deltalite-0.1.9-cp312-abi3-musllinux_1_2_aarch64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ ARM64 | Details |
| deltalite-0.1.9-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| deltalite-0.1.9-cp312-abi3-manylinux_2_28_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| deltalite-0.1.9-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details |
| deltalite-0.1.9-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 292.4 MB
Release files / deltalite-0.1.9.tar.gz
| Download URL | deltalite-0.1.9.tar.gz |
|---|---|
| Size | 219.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c63b9acde79a207eeb1d4106359a11b24ca3504484fe64db1f08b5f361475055
|
|
BLAKE2b-256 checksum How to use checksums |
b8bed67dd34c5bf6742e01bcc7ec9062e13fb57464b3aef13903308f0d038643
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / deltalite-0.1.9-cp312-abi3-musllinux_1_2_x86_64.whl
| Download URL | deltalite-0.1.9-cp312-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 63.7 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f946e3fda7f5fe209d48d5beb61b1d69ba91981e3be3fb425b1533d988429620
|
|
BLAKE2b-256 checksum How to use checksums |
0b7344c2332b81b99e128acfbcbe192b37c6a2fb977e7207871de67fb5b02917
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / deltalite-0.1.9-cp312-abi3-musllinux_1_2_aarch64.whl
| Download URL | deltalite-0.1.9-cp312-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 63.3 MB |
| Tags | CPython 3.12 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
3bf58cb2b74a09467c31a6b0fca929553099909790ad60788e6e5e964d14e729
|
|
BLAKE2b-256 checksum How to use checksums |
ebe62010899b9fca12359e55b5e2f2af45dc455f52979b3403b34239846d5813
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / deltalite-0.1.9-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | deltalite-0.1.9-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 65.9 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b834d020c873d9b7b1a62c0a43605d5a4acc90cb1775986416fc4a574e323b5e
|
|
BLAKE2b-256 checksum How to use checksums |
931f434b6e481231d05842278d8758a97a99b0c34df63183ff43ec6dcbbfa98f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / deltalite-0.1.9-cp312-abi3-manylinux_2_28_aarch64.whl
| Download URL | deltalite-0.1.9-cp312-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 63.7 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f5ecb12b239bc77e8a15d33215e966f6b35ecaaf5bc97b865aad8f9e54e06632
|
|
BLAKE2b-256 checksum How to use checksums |
c2b69291b8eb6d43599e61e8a81fb1adcb82e89c80f41df6ce10513aca789616
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / deltalite-0.1.9-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | deltalite-0.1.9-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 17.6 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
49df47aede53019ae98bdbdc567bdb279c34753e8c6579788125d173e97fa343
|
|
BLAKE2b-256 checksum How to use checksums |
d708542b8cf9d16edfd6084cc8599533b7c7a332e434709562da07f74a284025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency logRelease files / deltalite-0.1.9-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | deltalite-0.1.9-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 18.1 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d50d46f7b6e6b64a62996cb3bec809d2bf44d384cacfdfb9b36a1c334c78fa62
|
|
BLAKE2b-256 checksum How to use checksums |
3575752ae4a348fe5d12b0e0049aaf9c2978f7fd4396ae8dd1d4db722d1f87ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.
Transparency log