deltalake (delta-rs) Python merge: 'Schema error: Schema contains duplicate qualified field name "?table?".sid' and a merge that silently does nothing (forgot .execute())
Fix: give both sides an alias that matches your predicate, and end the builder chain with .execute():
from deltalake import DeltaTable
dt = DeltaTable(path)
(dt.merge(updates, # pyarrow Table / pandas / polars.to_arrow()
predicate="target.sid = source.sid",
source_alias="source", target_alias="target")
.when_matched_update_all()
.when_not_matched_insert_all()
.execute()) # returns metrics dictTwo mistakes I reproduced with deltalake 0.22.3:
1. Predicate with no aliases, e.g. dt.merge(upd, predicate="t.sid = s.sid"), raises DeltaError: Generic DeltaTable error: Schema error: Schema contains duplicate qualified field name "?table?".sid. Without source_alias/target_alias both tables are unnamed, so the column names collide. The message never mentions aliases.
2. dt.merge(...).when_matched_update_all().when_not_matched_insert_all() without .execute() returns a TableMerger builder and writes nothing. The table version stays at 0, and no error is raised.
With .execute() you get metrics like {'num_source_rows': 2, 'num_target_rows_inserted': 1, 'num_target_rows_updated': 1, 'num_target_rows_copied': 1, ...} and the table moves to version 1. Version 0 is still readable for time travel: DeltaTable(path, version=0).
Verify: check DeltaTable(path).version() before and after, and assert on the returned metrics rather than on the absence of an exception.