Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(data-warehouse): close the residual deltalite MERGE fallback causes (#83795)

Tom Owersf25833286a43
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_writer.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_writer.py
index 022d180c1072..ebc14b744ec7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_writer.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_writer.py
@@ -236,6 +236,62 @@ def _v3_batch(*, partitioned: bool = False) -> pa.Table:
return pa.table(data_dict)
+class TestNullabilityDriftGuardOrder:
+ """The nullability reset signal guards only the delta-rs MERGE fallback: deltalite
+ relaxes a lying non-nullable column in the table metadata and writes, so it must
+ receive the batch before the guard fires."""
+
+ def _seed_non_nullable_table(self, path: str) -> deltalake.DeltaTable:
+ schema = pa.schema(
+ [
+ pa.field("id", pa.int64(), nullable=False),
+ pa.field("v", pa.int64(), nullable=False),
+ ]
+ )
+ deltalake.write_deltalake(path, pa.table({"id": pa.array([1, 2]), "v": pa.array([1, 1])}, schema=schema))
+ return deltalake.DeltaTable(path)
+
+ def _null_carrying_batch(self) -> pa.Table:
+ # Deliberately NOT passed through evolve_pyarrow_schema: its non-nullable
+ # backfill would replace the nulls with defaults, and the guard exists exactly
+ # for batches that bypass that preamble.
+ return pa.table({"id": pa.array([2, 3], pa.int64()), "v": pa.array([None, 5], pa.int64())})
+
+ @pytest.mark.asyncio
+ async def test_merge_fallback_raises_reset_signal_on_null_in_non_nullable(self, tmp_path: Path) -> None:
+ delta_path = str(tmp_path / "table")
+ self._seed_non_nullable_table(delta_path)
+ helper = make_local_table_ref(delta_path)
+
+ # deltalite is off (the flag evaluation fails closed in tests), so the write falls
+ # through to the MERGE, which would silently store the nulls under a schema that
+ # denies them -- the guard must stop it with the reset signal instead.
+ with pytest.raises(SchemaColumnTypeChangedException, match="now contains nulls"):
+ await DeltaWriter(helper).write(
+ data=self._null_carrying_batch(),
+ write_type="incremental",
+ should_overwrite_table=False,
+ primary_keys=["id"],
+ )
+
+ @pytest.mark.asyncio
+ async def test_deltalite_write_bypasses_the_reset_signal(self, tmp_path: Path) -> None:
+ delta_path = str(tmp_path / "table")
+ self._seed_non_nullable_table(delta_path)
+ helper = make_local_table_ref(delta_path)
+
+ # deltalite handled the batch (it relaxes the column itself), so the guard must
+ # not fire -- firing here would reset tables deltalite can write fine.
+ with patch.object(DeltaWriter, "_write_via_deltalite", AsyncMock(return_value=True)):
+ result = await DeltaWriter(helper).write(
+ data=self._null_carrying_batch(),
+ write_type="incremental",
+ should_overwrite_table=False,
+ primary_keys=["id"],
+ )
+ assert result is not None
+
+
class TestLegacyDltTableReconciliation:
"""Pipeline_v3 must handle dlt-created Delta tables with NOT NULL _dlt_* columns."""
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/writer.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/writer.py
index fe96ae186840..0139235ba6f4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/writer.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/writer.py
@@ -340,11 +340,6 @@ class DeltaWriter:
# stored types up front so the merge cast is a no-op, or raise a clean reset signal.
data = align_incoming_decimals_to_delta(data, delta_table.schema())
- # A source that starts emitting nulls in a column the table created non-nullable is a
- # schema change under the table; neither deltalite nor delta-rs can relax it in place, so
- # raise the same reset signal to get the table fully re-synced.
- raise_on_nullability_drift(data, delta_table.schema())
-
existing_delta_table = delta_table
await self._logger.adebug(f"write: merging...")
@@ -382,6 +377,13 @@ class DeltaWriter:
commit_metadata=commit_metadata,
)
+ if not deltalite_wrote:
+ # A batch with nulls in a column the table declares non-nullable: deltalite relaxes
+ # the column to nullable in the table metadata and writes, but the delta-rs MERGE
+ # cannot relax in place and would silently write the nulls under a schema that
+ # denies them. Guard only the fallback path with the reset signal.
+ raise_on_nullability_drift(data, delta_table.schema())
+
if not deltalite_wrote and use_partitioning:
predicate_ops.append(f"source.{PARTITION_KEY} = target.{PARTITION_KEY}")
diff --git a/pyproject.toml b/pyproject.toml
index 3213ed1d7a68..0f6aff7a8f54 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -204,7 +204,7 @@ dependencies = [
"braintrust-core>=0.0.59,<1",
"wrapt==1.17.3",
"limits==5.8.0",
- "deltalite==0.1.6",
+ "deltalite==0.1.7",
]
[dependency-groups]
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 6127ccf236b4..850e7e4bbebd 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -3715,7 +3715,7 @@ dependencies = [
[[package]]
name = "deltalite-python"
-version = "0.1.6"
+version = "0.1.7"
dependencies = [
"arrow",
"arrow-array",
diff --git a/rust/deltalite/core/src/upsert.rs b/rust/deltalite/core/src/upsert.rs
index 358af2b385de..93d9b624ead9 100644
--- a/rust/deltalite/core/src/upsert.rs
+++ b/rust/deltalite/core/src/upsert.rs
@@ -32,7 +32,8 @@ use arrow_schema::{DataType, Field, Schema, SchemaRef};
use arrow_select::filter::filter_record_batch;
use arrow_select::take::{take, take_record_batch};
use deltalake::kernel::transaction::{CommitBuilder, CommitProperties};
-use deltalake::kernel::{Action, Remove};
+use deltalake::kernel::{Action, MetadataExt as _, Remove, StructType};
+use deltalake::protocol::checkpoints::{cleanup_metadata, create_checkpoint};
use deltalake::protocol::{DeltaOperation, SaveMode};
use deltalake::table::config::TablePropertiesExt;
use deltalake::writer::{DeltaWriter, RecordBatchWriter};
@@ -45,7 +46,7 @@ use parquet::arrow::ProjectionMask;
use parquet::file::metadata::ParquetMetaData;
use serde_json::Value;
use tokio::sync::{mpsc, OwnedSemaphorePermit, Semaphore};
-use tracing::{debug, info, instrument};
+use tracing::{debug, info, instrument, warn};
use crate::errors::{Error, Result};
use crate::limits::{
@@ -247,6 +248,9 @@ pub struct UpsertStats {
pub rewrite_ms: u64,
/// Wall-clock ms spent committing the new file set to the Delta log.
pub commit_ms: u64,
+ /// Non-nullable columns relaxed to nullable before this upsert because the table's
+ /// data (or this batch) already contains nulls in them.
+ pub columns_relaxed: usize,
}
/// A file selected for rewrite, with the metadata needed to tombstone it.
@@ -490,7 +494,7 @@ pub async fn upsert(
) -> Result<UpsertStats> {
let started = Instant::now();
let strategy = opts.prune_strategy.as_str();
- let result = upsert_inner(table, source_batches, source_schema, opts).await;
+ let result = upsert_with_relax(table, source_batches, source_schema, opts).await;
// Static label values only -- no per-call allocation (rust/CLAUDE.md).
histogram!("deltalite_upsert_duration_seconds").record(started.elapsed().as_secs_f64());
@@ -520,6 +524,154 @@ pub async fn upsert(
result
}
+/// Relax lying non-nullable columns before the upsert proper.
+///
+/// A table can declare a column non-nullable while its files already hold nulls in it:
+/// the delta-rs MERGE writes such rows without complaint, so tables that ever took that
+/// path are permanently poisoned for deltalite, whose partition rewrite re-reads those
+/// files and fails Arrow's nullability validation on every subsequent upsert. Flipping
+/// the column to nullable in the table metadata is protocol-legal, matches the state a
+/// reset-and-resync would produce, and is the only honest description of the data that
+/// is already there. The same applies to a batch that carries (or null-pads) nulls in a
+/// non-nullable column: without the relax the write fails; with the fallback it writes
+/// nulls under a schema that denies them.
+async fn upsert_with_relax(
+ table: &DeltaTable,
+ source_batches: Vec<RecordBatch>,
+ source_schema: SchemaRef,
+ opts: UpsertOptions,
+) -> Result<UpsertStats> {
+ let relax = columns_needing_relax(table, &source_batches, &source_schema).await?;
+ if relax.is_empty() {
+ return upsert_inner(table, source_batches, source_schema, opts).await;
+ }
+
+ relax_columns_to_nullable(table, &relax).await?;
+ // Re-read the log so the writer (and every schema derived from the table) observes
+ // the relaxed metadata; the borrowed handle still sees the old snapshot.
+ let mut fresh = table.clone();
+ fresh.update_incremental(None).await?;
+ let mut stats = upsert_inner(&fresh, source_batches, source_schema, opts).await?;
+ stats.columns_relaxed = relax.len();
+ Ok(stats)
+}
+
+/// Non-nullable table columns that verifiably contain nulls -- in the incoming batch
+/// (present with nulls, or absent so the cast will null-pad it) or in the table's own
+/// files (Add-action `nullCount` stats). Only positive evidence relaxes: files without
+/// stats are left alone, so a clean table's schema is never touched.
+async fn columns_needing_relax(
+ table: &DeltaTable,
+ source_batches: &[RecordBatch],
+ source_schema: &Schema,
+) -> Result<Vec<String>> {
+ let snapshot = table.snapshot()?;
+ let non_nullable: Vec<String> = snapshot
+ .schema()
+ .fields()
+ .filter(|f| !f.nullable)
+ .map(|f| f.name().to_string())
+ .collect();
+ if non_nullable.is_empty() {
+ return Ok(vec![]);
+ }
+
+ let mut relax: Vec<String> = Vec::new();
+ let mut unresolved: Vec<String> = Vec::new();
+ for name in non_nullable {
+ match source_schema.index_of(&name) {
+ Err(_) => relax.push(name),
+ Ok(idx) => {
+ if source_batches
+ .iter()
+ .any(|b| b.column(idx).null_count() > 0)
+ {
+ relax.push(name);
+ } else {
+ unresolved.push(name);
+ }
+ }
+ }
+ }
+
+ if !unresolved.is_empty() {
+ let views: Vec<_> = table
+ .get_active_add_actions_by_partitions(&[])
+ .try_collect()
+ .await?;
+ 'files: for v in views {
+ let Some(stats) = v.stats() else { continue };
+ let Ok(parsed) = serde_json::from_str::<Value>(&stats) else {
+ continue;
+ };
+ let Some(nulls) = parsed.get("nullCount") else {
+ continue;
+ };
+ let mut i = 0;
+ while i < unresolved.len() {
+ if nulls
+ .get(&unresolved[i])
+ .and_then(Value::as_i64)
+ .unwrap_or(0)
+ > 0
+ {
+ relax.push(unresolved.swap_remove(i));
+ if unresolved.is_empty() {
+ break 'files;
+ }
+ } else {
+ i += 1;
+ }
+ }
+ }
+ }
+
+ relax.sort();
+ Ok(relax)
+}
+
+/// Commit a metadata action flipping `columns` to nullable. Runs as its own commit so
+/// the upsert that follows plans against the relaxed schema; concurrent writers see a
+/// MetadataChanged conflict and re-plan (or fall back), exactly as for any other
+/// schema evolution.
+async fn relax_columns_to_nullable(table: &DeltaTable, columns: &[String]) -> Result<()> {
+ let snapshot = table.snapshot()?;
+ let schema = snapshot.schema();
+ let relaxed = StructType::try_new(schema.fields().map(|f| {
+ let mut field = f.clone();
+ if columns.iter().any(|c| c == f.name()) {
+ field.nullable = true;
+ }
+ field
+ }))
+ .map_err(|e| Error::Generic(format!("cannot build relaxed schema: {e}")))?;
+
+ let metadata = snapshot
+ .metadata()
+ .clone()
+ .with_schema(&relaxed)
+ .map_err(|e| Error::Generic(format!("cannot update table metadata: {e}")))?;
+ let operation = DeltaOperation::UpdateFieldMetadata {
+ fields: relaxed.fields().cloned().collect(),
+ };
+
+ CommitBuilder::from(
+ CommitProperties::default()
+ .with_create_checkpoint(false)
+ .with_cleanup_expired_logs(Some(false)),
+ )
+ .with_actions(vec![metadata.into()])
+ .build(Some(snapshot), table.log_store(), operation)
+ .await?;
+
+ info!(
+ columns = ?columns,
+ "relaxed non-nullable columns that already contain nulls to nullable"
+ );
+ counter!("deltalite_columns_relaxed_total").increment(columns.len() as u64);
+ Ok(())
+}
+
async fn upsert_inner(
table: &DeltaTable,
mut source_batches: Vec<RecordBatch>,
@@ -735,17 +887,32 @@ async fn upsert_inner(
predicate,
};
- let mut props = CommitProperties::default().with_max_retries(opts.commit_max_retries);
+ // Checkpoint + expired-log cleanup are kept OUT of delta-rs's post-commit hook: a
+ // hook failure (e.g. an S3 hiccup on the DeleteObjects call behind log cleanup)
+ // propagates as an upsert error AFTER the commit is already durable, sending the
+ // caller back to the delta-rs MERGE for a write that has in fact happened. They run
+ // best-effort below instead.
+ let mut props = CommitProperties::default()
+ .with_max_retries(opts.commit_max_retries)
+ .with_create_checkpoint(false)
+ .with_cleanup_expired_logs(Some(false));
if let Some(md) = opts.commit_metadata.clone() {
props = props.with_metadata(md);
}
+ let checkpoint_interval = snapshot.table_config().checkpoint_interval().get();
+ let cleanup_enabled = snapshot.table_config().enable_expired_log_cleanup();
+
let finalized = CommitBuilder::from(props)
.with_actions(actions)
.build(Some(snapshot), table.log_store(), operation)
.await?;
let commit_ms = commit_started.elapsed().as_millis() as u64;
+ if (finalized.version() + 1) % checkpoint_interval == 0 {
+ best_effort_log_maintenance(table, finalized.version(), cleanup_enabled).await;
+ }
+
stats.plan_ms = plan_ms;
stats.rewrite_ms = rewrite_ms;
stats.commit_ms = commit_ms;
@@ -769,6 +936,42 @@ async fn upsert_inner(
Ok(stats)
}
+/// Checkpoint and expired-log cleanup after a durable commit, tolerating failure: the
+/// data is committed, so a maintenance error must never fail the upsert -- it is logged
+/// and the next boundary commit retries. The caller gates this on the table's
+/// `checkpoint_interval` boundary; cleanup therefore also runs per boundary rather than
+/// per commit (as delta-rs's hook does) -- cleanup can only delete logs behind a
+/// checkpoint anyway, and gating it cuts the bulk-delete traffic by the interval factor.
+async fn best_effort_log_maintenance(table: &DeltaTable, version: u64, cleanup_enabled: bool) {
+ let result: std::result::Result<(), (&'static str, deltalake::DeltaTableError)> = async {
+ let mut post = table.clone();
+ post.update_incremental(None)
+ .await
+ .map_err(|e| ("refresh", e))?;
+ create_checkpoint(&post, None)
+ .await
+ .map_err(|e| ("checkpoint", e))?;
+ if cleanup_enabled {
+ cleanup_metadata(&post, None)
+ .await
+ .map_err(|e| ("cleanup", e))?;
+ }
+ Ok(())
+ }
+ .await;
+
+ if let Err((op, e)) = result {
+ warn!(
+ version,
+ op,
+ error = %e,
+ "post-commit log maintenance failed; the commit itself is durable and the \
+ next checkpoint-boundary commit retries"
+ );
+ counter!("deltalite_log_maintenance_failures_total", "op" => op).increment(1);
+ }
+}
+
/// Explicit argument > table property (already folded with delta-rs's default by the
/// caller). Zero/absent explicit values fall through to the table's value.
fn resolve_target_file_size(explicit: Option<usize>, table_value: usize) -> usize {
diff --git a/rust/deltalite/python/Cargo.toml b/rust/deltalite/python/Cargo.toml
index 0d89cc7fccfc..1d0fd1f2ae95 100644
--- a/rust/deltalite/python/Cargo.toml
+++ b/rust/deltalite/python/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "deltalite-python"
# Mirrors pyproject.toml in this directory (always identical); bump both together.
-version = "0.1.6"
+version = "0.1.7"
edition = "2021"
# CI compiles with this exact toolchain; cargo's MSRV-aware resolver uses it to
# avoid picking dependency versions CI cannot build (aws-* crates move MSRV often).
diff --git a/rust/deltalite/python/pyproject.toml b/rust/deltalite/python/pyproject.toml
index b68d8907ced1..57e8a207d186 100644
--- a/rust/deltalite/python/pyproject.toml
+++ b/rust/deltalite/python/pyproject.toml
@@ -10,7 +10,7 @@ build-backend = "maturin"
[project]
name = "deltalite"
# Mirrors `rust/deltalite/python/Cargo.toml` (always identical); bump both together.
-version = "0.1.6"
+version = "0.1.7"
description = "Streaming partition upsert for Delta tables, replacing delta-rs SQL MERGE"
readme = "README.md"
requires-python = ">=3.12"
diff --git a/rust/deltalite/python/src/lib.rs b/rust/deltalite/python/src/lib.rs
index 2316ebc78342..3e61a783109d 100644
--- a/rust/deltalite/python/src/lib.rs
+++ b/rust/deltalite/python/src/lib.rs
@@ -167,6 +167,8 @@ pub struct UpsertStats {
pub rewrite_ms: u64,
#[pyo3(get)]
pub commit_ms: u64,
+ #[pyo3(get)]
+ pub columns_relaxed: usize,
}
#[pymethods]
@@ -206,6 +208,7 @@ impl From<deltalite_core::upsert::UpsertStats> for UpsertStats {
plan_ms: s.plan_ms,
rewrite_ms: s.rewrite_ms,
commit_ms: s.commit_ms,
+ columns_relaxed: s.columns_relaxed,
}
}
}
diff --git a/rust/deltalite/python/tests/test_operations.py b/rust/deltalite/python/tests/test_operations.py
index 52a7649df286..885edeed70a4 100644
--- a/rust/deltalite/python/tests/test_operations.py
+++ b/rust/deltalite/python/tests/test_operations.py
@@ -809,3 +809,165 @@ def test_large_source_is_also_split_by_the_target(tmp_path):
sizes = _added_file_sizes(uri, stats.version)
assert stats.files_added > 1, f"source write ignored the 4 MiB target: {stats}"
assert max(sizes) < 32 * 1024 * 1024, f"file far larger than the target: {sizes}"
+
+
+# --------------------------------------------------------------------------------------
+# Nullability relax: lying non-nullable columns are flipped to nullable, not failed
+# --------------------------------------------------------------------------------------
+
+
+def _non_nullable_table(uri):
+ schema = pa.schema(
+ [
+ pa.field("id", pa.string(), nullable=False),
+ pa.field("v", pa.int64(), nullable=False),
+ pa.field(PARTITION_KEY, pa.string(), nullable=False),
+ ]
+ )
+ data = pa.table({"id": ["a", "b"], "v": [1, 1], PARTITION_KEY: ["p", "p"]}, schema=schema)
+ create_table(uri, data, partitioned=True)
+
+
+def _nullability(uri) -> dict[str, bool]:
+ return {f.name: f.nullable for f in deltalake.DeltaTable(uri).schema().fields}
+
+
+def test_upsert_relaxes_non_nullable_column_when_batch_carries_nulls(tmp_path):
+ """A batch with nulls in a non-nullable column relaxes that column to nullable in
+ the table metadata and commits, instead of failing Arrow's nullability validation
+ (which sent production back to the delta-rs MERGE -- which then wrote the nulls
+ anyway, under a schema that denies them)."""
+ uri = str(tmp_path / "relax_batch")
+ _non_nullable_table(uri)
+
+ batch = pa.table(
+ {
+ "id": pa.array(["b", "c"], pa.string()),
+ "v": pa.array([2, None], pa.int64()),
+ PARTITION_KEY: pa.array(["p", "p"], pa.string()),
+ }
+ )
+ stats = upsert_path(uri, batch, ["id"], PARTITION_KEY)
+
+ assert stats.columns_relaxed == 1
+ nullability = _nullability(uri)
+ assert nullability["v"] is True, "the null-carrying column must be relaxed"
+ assert nullability["id"] is False, "untouched columns keep their nullability"
+ assert content(uri) == {("a", "p"): 1, ("b", "p"): 2, ("c", "p"): None}
+
+
+def test_upsert_relaxes_non_nullable_column_absent_from_batch(tmp_path):
+ """A batch missing a non-nullable column gets it null-padded (the pinned wholesale
+ row-replacement semantics), which requires the same relax."""
+ uri = str(tmp_path / "relax_absent")
+ _non_nullable_table(uri)
+
+ batch = pa.table(
+ {
+ "id": pa.array(["b", "c"], pa.string()),
+ PARTITION_KEY: pa.array(["p", "p"], pa.string()),
+ }
+ )
+ stats = upsert_path(uri, batch, ["id"], PARTITION_KEY)
+
+ assert stats.columns_relaxed == 1
+ assert _nullability(uri)["v"] is True
+ assert content(uri) == {("a", "p"): 1, ("b", "p"): None, ("c", "p"): None}
+
+
+def test_upsert_heals_table_poisoned_by_historic_null_writes(tmp_path):
+ """The production failure shape: files contain real nulls in a column the schema
+ declares non-nullable (older writers accepted them; current ones refuse), so every
+ later deltalite upsert re-reads a poisoned file and fails validation -- permanently.
+ Poisoning is reproduced by writing the nulls under a nullable schema and then
+ flipping the metaData action's nullable flag, since current writers refuse the
+ direct write. The Add-action nullCount stats prove the nulls, the column is relaxed,
+ and the upsert (with a perfectly clean batch) succeeds."""
+ uri = str(tmp_path / "relax_poisoned")
+ data = pa.table(
+ {
+ "id": pa.array(["a", "b", "c"], pa.string()),
+ "v": pa.array([1, 1, None], pa.int64()),
+ PARTITION_KEY: pa.array(["p", "p", "p"], pa.string()),
+ }
+ )
+ create_table(uri, data, partitioned=True)
+
+ commit0 = Path(uri) / "_delta_log" / "00000000000000000000.json"
+ lines = []
+ for line in commit0.read_text().splitlines():
+ action = json.loads(line)
+ if "metaData" in action:
+ schema = json.loads(action["metaData"]["schemaString"])
+ for field in schema["fields"]:
+ if field["name"] == "v":
+ field["nullable"] = False
+ action["metaData"]["schemaString"] = json.dumps(schema)
+ lines.append(json.dumps(action))
+ commit0.write_text("\n".join(lines) + "\n")
+ assert _nullability(uri)["v"] is False, "test setup must produce the lying schema"
+
+ clean = pa.table(
+ {
+ "id": pa.array(["a", "d"], pa.string()),
+ "v": pa.array([5, 5], pa.int64()),
+ PARTITION_KEY: pa.array(["p", "p"], pa.string()),
+ }
+ )
+ stats = upsert_path(uri, clean, ["id"], PARTITION_KEY)
+
+ assert stats.columns_relaxed == 1
+ assert _nullability(uri)["v"] is True
+ assert content(uri) == {("a", "p"): 5, ("b", "p"): 1, ("c", "p"): None, ("d", "p"): 5}
+
+
+def test_upsert_does_not_relax_clean_non_nullable_columns(tmp_path):
+ """No false positives: a clean table + clean batch leaves the schema untouched."""
+ uri = str(tmp_path / "no_relax")
+ _non_nullable_table(uri)
+
+ batch = pa.table(
+ {
+ "id": pa.array(["b", "c"], pa.string()),
+ "v": pa.array([2, 3], pa.int64()),
+ PARTITION_KEY: pa.array(["p", "p"], pa.string()),
+ }
+ )
+ stats = upsert_path(uri, batch, ["id"], PARTITION_KEY)
+
+ assert stats.columns_relaxed == 0
+ nullability = _nullability(uri)
+ assert nullability["v"] is False
+ assert nullability["id"] is False
+ assert content(uri) == {("a", "p"): 1, ("b", "p"): 2, ("c", "p"): 3}
+
+
+# --------------------------------------------------------------------------------------
+# Best-effort log maintenance: checkpoints still happen without the post-commit hook
+# --------------------------------------------------------------------------------------
+
+
+def test_upsert_creates_checkpoint_at_interval_boundary(tmp_path):
+ """Checkpoint + log cleanup moved out of delta-rs's post-commit hook (where a
+ failure fails the already-durable commit) into a best-effort step. This pins that
+ checkpoints still get created at the table's checkpointInterval boundary."""
+ uri = str(tmp_path / "checkpointed")
+ deltalake.write_deltalake(
+ uri,
+ simple(["a"], "p", 1),
+ partition_by=[PARTITION_KEY],
+ mode="overwrite",
+ configuration={"delta.checkpointInterval": "2"},
+ )
+
+ stats = upsert_path(uri, simple(["b"], "p", 2), ["id"], PARTITION_KEY)
+ assert stats.version == 1
+
+ log = Path(uri) / "_delta_log"
+ checkpoints = list(log.glob("*.checkpoint.parquet"))
+ assert checkpoints, "the boundary commit ((version + 1) % interval == 0) must checkpoint"
+ assert (log / "_last_checkpoint").exists()
+
+ # An off-boundary commit must not add another checkpoint.
+ upsert_path(uri, simple(["c"], "p", 3), ["id"], PARTITION_KEY)
+ assert list(log.glob("*.checkpoint.parquet")) == checkpoints
diff --git a/uv.lock b/uv.lock
index 3171ae0d1291..7dee6f049b35 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1744,16 +1744,16 @@ pyarrow = [
[[package]]
name = "deltalite"
-version = "0.1.6"
+version = "0.1.7"
source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/e6/07/51964c17d24dce50a90e617e959dac50bd6ee961ec1d30149a11221435da/deltalite-0.1.6.tar.gz", hash = "sha256:b5f8f728ad12be62875e01e7959e761d0fb350b3279571d32727aa959e78fb4c", size = 175456, upload-time = "2026-08-10T12:43:28.963Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/ee/ba/e08c970ed75b05cc3fe406f404eff1f68e82d399283e6937d8ebb8699401/deltalite-0.1.7.tar.gz", hash = "sha256:3239569df220821765ab9d7dc7a0e58cfbe6256670c29bbdc7df25a07eef7ce7", size = 179136, upload-time = "2026-08-17T14:27:49.6Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/8c/3b/c28f2fcba6ebbbab14a7781108956a288e5e275d6ae342c3641d56ff410b/deltalite-0.1.6-cp312-abi3-macosx_10_12_x86_64.whl", hash = "sha256:6fbdbe6e110c738f567b2bd01e79897479f11989b437735daab7b144c5267503", size = 17964670, upload-time = "2026-08-10T12:43:08.032Z" },
- { url = "https://files.pythonhosted.org/packages/db/a2/917ca2215a7c54ce42f7b3669c7917d1b5470b236c5d680d8ec83f065cc1/deltalite-0.1.6-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:b4ad22983bfbc8335c7880b7d9a2bc8d575f2225b05437f426ec86ceb060891b", size = 17852501, upload-time = "2026-08-10T12:43:11.098Z" },
- { url = "https://files.pythonhosted.org/packages/16/81/27ca3a8da82ae61c556dbf648bb9ff9eeaf400b03d32b8a7429f2dac5fce/deltalite-0.1.6-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:5308c408502aca987f1a315621fbe5937301263e4a236971525db2d5bc98df89", size = 63172312, upload-time = "2026-08-10T12:43:14.383Z" },
- { url = "https://files.pythonhosted.org/packages/cf/fa/07d484ef2f8db20ad8841b91084edd0e885fe2c4a7f9e7e7f44aa6210a4d/deltalite-0.1.6-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:dfbccd799364847e262004acb5dc61d6e373ed79ac9e0e0bf5fae8c4aacfce2d", size = 65472792, upload-time = "2026-08-10T12:43:18.12Z" },
- { url = "https://files.pythonhosted.org/packages/4f/3c/a05a0addbf7b9ca333ded94b360782afd6b9bdd163b665bdf13143cb5d12/deltalite-0.1.6-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:701e7093ff60ed2e6764caf1c8846430f71714b469ac0dcc052740c00fca5f80", size = 62768622, upload-time = "2026-08-10T12:43:22.397Z" },
- { url = "https://files.pythonhosted.org/packages/d1/7a/0039dcf77fdfe54962311e5f61491f4155e761f7059f1c331ae0c594e399/deltalite-0.1.6-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b267a1adbc22ed802475dbf9e6ea629275c0dc99a77b6c119bd9909d5965ca54", size = 63835586, upload-time = "2026-08-10T12:43:26.654Z" },
+ { url = "https://files.pythonhosted.org/packages/ce/19/339cef01f049c2baa873266788be9bd9083b20025adfc82cf82cd680b030/deltalite-0.1.7-cp312-abi3-macosx_10_12_x86_64.whl", hash = "sha256:a9617a7a13b3e2dad34345130846b4bae67e940b5c7a82982024d9aad116a193", size = 18099239, upload-time = "2026-08-17T14:27:15.681Z" },
+ { url = "https://files.pythonhosted.org/packages/d4/e1/f4d68be53a8a0786d06cd87aeb06f6bf91f3c8af87a5d382e9ff8200fb27/deltalite-0.1.7-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:211f6d4ca4c0168d5a43c7acdcf0feb5cc53f80ce9febaab3341cdbbece8b501", size = 17977129, upload-time = "2026-08-17T14:27:19.148Z" },
+ { url = "https://files.pythonhosted.org/packages/1e/53/c69bf668d442e514f7ab2443c14831e6241fd0151cec2acfd429e6298ad8/deltalite-0.1.7-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:e6e5bf4e90e7459d4538f4270e5c70e5b41750fd91c41e84aba311b5ad93d810", size = 63527353, upload-time = "2026-08-17T14:27:25.14Z" },
+ { url = "https://files.pythonhosted.org/packages/81/ef/a6b7ea3d6367875c6fb9138ca08d70df1c5f4b6200d9649a7773fd1cbb77/deltalite-0.1.7-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:854f3657dccbc48cce11d5c1cd90dd92f3c4c897ef1c274a3ebae06aea5fcb65", size = 65821240, upload-time = "2026-08-17T14:27:32.393Z" },
+ { url = "https://files.pythonhosted.org/packages/2e/7f/405fd089c8e3f56c51d6aec13586d729cd991f0b9e8aace5e3a2e30a180f/deltalite-0.1.7-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:8d432f322bc9546453ed895f6c68e5fe2be8b43143642329bb7c828f958ee4f4", size = 63114142, upload-time = "2026-08-17T14:27:39.4Z" },
+ { url = "https://files.pythonhosted.org/packages/f6/77/89f31c64f7ce7d05e48b638652b284e8a8ce356c06c4124002d853bae22b/deltalite-0.1.7-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ceb20644b87642e8265de01f4b89286891e75ddba226914e4100db561cfde1c7", size = 64181696, upload-time = "2026-08-17T14:27:46.91Z" },
]
[[package]]
@@ -4680,7 +4680,7 @@ name = "nvidia-cudnn-cu12"
version = "9.10.2.21"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "nvidia-cublas-cu12", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
+ { name = "nvidia-cublas-cu12" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/ba/51/e123d997aa098c61d029f76663dedbfb9bc8dcf8c60cbd6adbe42f76d049/nvidia_cudnn_cu12-9.10.2.21-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:949452be657fa16687d0930933f032835951ef0892b37d2d53824d1a84dc97a8", size = 706758467, upload-time = "2025-06-06T21:54:08.597Z" },
@@ -4691,7 +4691,7 @@ name = "nvidia-cufft-cu12"
version = "11.3.3.83"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "nvidia-nvjitlink-cu12", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
+ { name = "nvidia-nvjitlink-cu12" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/1f/13/ee4e00f30e676b66ae65b4f08cb5bcbb8392c03f54f2d5413ea99a5d1c80/nvidia_cufft_cu12-11.3.3.83-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4d2dd21ec0b88cf61b62e6b43564355e5222e4a3fb394cac0db101f2dd0d4f74", size = 193118695, upload-time = "2025-03-07T01:45:27.821Z" },
@@ -4718,9 +4718,9 @@ name = "nvidia-cusolver-cu12"
version = "11.7.3.90"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "nvidia-cublas-cu12", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
- { name = "nvidia-cusparse-cu12", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
- { name = "nvidia-nvjitlink-cu12", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
+ { name = "nvidia-cublas-cu12" },
+ { name = "nvidia-cusparse-cu12" },
+ { name = "nvidia-nvjitlink-cu12" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/85/48/9a13d2975803e8cf2777d5ed57b87a0b6ca2cc795f9a4f59796a910bfb80/nvidia_cusolver_cu12-11.7.3.90-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:4376c11ad263152bd50ea295c05370360776f8c3427b30991df774f9fb26c450", size = 267506905, upload-time = "2025-03-07T01:47:16.273Z" },
@@ -4731,7 +4731,7 @@ name = "nvidia-cusparse-cu12"
version = "12.5.8.93"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "nvidia-nvjitlink-cu12", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
+ { name = "nvidia-nvjitlink-cu12" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/c2/f5/e1854cb2f2bcd4280c44736c93550cc300ff4b8c95ebe370d0aa7d2b473d/nvidia_cusparse_cu12-12.5.8.93-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1ec05d76bbbd8b61b06a80e1eaf8cf4959c3d4ce8e711b65ebd0443bb0ebb13b", size = 288216466, upload-time = "2025-03-07T01:48:13.779Z" },
@@ -5390,7 +5390,7 @@ name = "pexpect"
version = "4.9.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "ptyprocess", marker = "sys_platform != 'emscripten'" },
+ { name = "ptyprocess" },
]
sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" }
wheels = [
@@ -5878,7 +5878,7 @@ requires-dist = [
{ name = "databricks-sql-connector", specifier = "~=4.3.0" },
{ name = "defusedxml", specifier = "~=0.7.1" },
{ name = "deltalake", extras = ["pyarrow"], specifier = "==1.6.1" },
- { name = "deltalite", specifier = "==0.1.6" },
+ { name = "deltalite", specifier = "==0.1.7" },
{ name = "disposable-email-domains", specifier = "~=0.0.140" },
{ name = "dj-database-url", specifier = "~=3.0.0" },
{ name = "django", specifier = "~=5.2.0" },
@@ -7670,7 +7670,7 @@ name = "shadowcopy"
version = "0.0.4"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "wmi", marker = "sys_platform != 'emscripten'" },
+ { name = "wmi" },
]
sdist = { url = "https://files.pythonhosted.org/packages/12/44/c00420a3b7bcdf830529b933392b566c876a4944a24f31e126eb6fd28647/shadowcopy-0.0.4.tar.gz", hash = "sha256:ed89817dda065f893607a04c0b7d6b3b34c3507a4711f441111a4bcb1b1826c0", size = 4138, upload-time = "2023-07-08T00:01:35.266Z" }
wheels = [
@@ -8104,7 +8104,7 @@ name = "tbb"
version = "2022.3.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "tcmlib", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
+ { name = "tcmlib" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/08/59/8d381a2cfe8d36c4f4ff9f94769ff2809bfc16014d888360b0e24c7e5c6b/tbb-2022.3.1-py2.py3-none-manylinux_2_28_x86_64.whl", hash = "sha256:534c089eca6bcf148408684c156229d5f09c01d323b685b15739f41985b529d7", size = 4178630, upload-time = "2026-01-22T05:30:20.589Z" },
@@ -8486,7 +8486,7 @@ name = "triton"
version = "3.4.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "setuptools", marker = "platform_machine != 's390x' and sys_platform != 'emscripten'" },
+ { name = "setuptools" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/30/7b/0a685684ed5322d2af0bddefed7906674f67974aa88b0fae6e82e3b766f6/triton-3.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00be2964616f4c619193cb0d1b29a99bd4b001d7dc333816073f92cf2a8ccdeb", size = 155569223, upload-time = "2025-07-30T19:58:44.017Z" },
@@ -9193,7 +9193,7 @@ name = "wmi"
version = "1.5.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "pywin32", marker = "sys_platform != 'emscripten'" },
+ { name = "pywin32" },
]
sdist = { url = "https://files.pythonhosted.org/packages/d4/66/6364deb0a03415f96c66803d8c4379f808f2401da3bdb183348487b10510/WMI-1.5.1.tar.gz", hash = "sha256:b6a6be5711b1b6c8d55bda7a8befd75c48c12b770b9d227d31c1737dbf0d40a6", size = 26254, upload-time = "2020-04-28T08:22:58.096Z" }
wheels = [