Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c2c1e07
fix(databases)!: enforce database write rules (ITL-1386)
eywalker Nov 28, 2026
c7f79d7
fix(databases): allow Delta appends with unrecorded extension metadat…
eywalker Nov 28, 2026
1e48d3d
fix(databases): preserve Delta append metadata and reuse strict write…
eywalker Nov 28, 2026
6f11cbe
fix(databases): keep the readable snapshot after a failed Delta refresh
eywalker Nov 28, 2026
d4a4cc2
fix(delta): allow appends with unknown IPC extension storage metadata
eywalker Nov 28, 2026
2123aef
fix(delta): compare duplicate IDs using Arrow storage values
eywalker Nov 28, 2026
3db039f
fix(delta): compare composite extension record IDs
eywalker Nov 28, 2026
bb141c7
fix(delta): preserve typed record IDs during duplicate checks
eywalker Nov 28, 2026
296f291
fix(databases): honor stored struct IDs and known IPC metadata
eywalker Nov 28, 2026
4d0a81a
fix(delta): refuse mismatched nested record ID types
eywalker Nov 28, 2026
f702e41
chore(delta): integrate main’s Delta load safeguards
eywalker Nov 28, 2026
8c08ee1
fix(sqlite): preserve replacement for separate unique constraints
eywalker Nov 28, 2026
feb8957
chore: merge main into ITL-1386
eywalker Nov 28, 2026
3c4bcdd
test(delta): verify persisted rows after a conflicting flush
eywalker Nov 28, 2026
0428941
chore: merge main into ITL-1386
eywalker Nov 28, 2026
17cf1c2
chore: merge main into ITL-1386
eywalker Nov 29, 2026
147c3b2
chore: merge main into ITL-1386
eywalker Nov 29, 2026
8c8b073
fix(delta): check persisted timestamp IDs after lossy writes
eywalker Nov 29, 2026
73a1385
Merge remote-tracking branch 'origin/main' into eywalker/itl-1386-a-w…
eywalker Nov 29, 2026
e9122fd
fix(delta): refresh IDs after native temporal conversions
eywalker Nov 29, 2026
d65eb4b
Merge remote-tracking branch 'origin/main' into eywalker/itl-1386-a-w…
eywalker Nov 29, 2026
db43778
fix(delta): restore reviewed ID cache behavior
eywalker Nov 29, 2026
597bbbf
fix(delta): compare nested timestamp IDs in one unit
eywalker Nov 29, 2026
7535eec
chore(merge): resolve main conflicts for ITL-1386
eywalker Nov 29, 2026
1d3bcf9
fix(databases): tighten stored record ID checks
eywalker Nov 29, 2026
fb1d67b
chore(merge): sync ITL-907 from main
eywalker Nov 29, 2026
aa37cc6
test(sources): repair stored fixture without a duplicate append
eywalker Nov 29, 2026
1cb4bdd
fix(databases): look up only incoming strict append IDs
eywalker Nov 29, 2026
c6c955b
chore(merge): sync main into ITL-1386
eywalker Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions changelog.d/ITL-1386.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
### Breaking changes and migration

- `add_record` and `add_records` now raise `ValueError` with the default
`skip_duplicates=False` when a record ID is already stored or pending. A batch
rejected for a duplicate queues no rows. Use `skip_duplicates=True` for
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
write-if-missing behavior. If another writer commits an ID after the add-time
check, the first commit keeps the row. SQLite still applies its existing
replace or ignore policy when only a separate unique constraint conflicts.
(ITL-1386, ITL-1487)

### Fixed

- Delta accepts extension-backed record IDs outside Python's date range and
skips late duplicate list and struct IDs when flushing. (ITL-1386)
- Delta rejects a changed nested record ID storage type before queueing the add,
including when an append omits a nullable field inside the ID. (ITL-1386)
- Delta compares nested timestamp IDs across the input and stored timestamp units.
(ITL-1386)
- Delta checks nested extension storage types before skipping a matching stored
ID. Connector-backed databases report a failed stored-ID lookup as a read
error. Writable connectors implement `existing_record_ids` to check only the
incoming IDs by primary key. (ITL-1386)
- Appends reject mismatches in known field metadata inside Arrow extension
storage. Delta accepts IPC-decoded whole-column extensions that are
unregistered when the existing append checks pass. (ITL-1415)
- Delta excludes the record ID column from data-skipping statistics for every ID
type so concurrent MERGEs detect conflicting writes. The statistics property
is written at table creation. Tables created earlier keep their settings.
(ITL-1444)

### Known limitations

- If Delta cannot refresh its cached snapshot, a successful strict add can
also miss an ID another writer committed before the add-time check. A
successful flush keeps the stored row. (ITL-1386)
- As before, with Delta's `schema_handling="coerce"`, strict adds can miss
duplicate IDs that become equal when cast to the pending batch's type.
(ITL-1662)
- After a Delta commit, the log has no metadata for list items or map keys and
values inside extension storage. Appends can compare those fields against
queued rows only. A create file's Parquet footer can carry list item metadata,
while files written by a later MERGE can omit it. (ITL-1415)
4 changes: 2 additions & 2 deletions docs/dev/design_issues/ITL-1377-CW1.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ table does not hold (`_commit_once`), with `streamed_exec=False`.
so a create that lost the race fails and is retried as a MERGE. Without that, deltalake
1.6 commits the losing create on top of the winner's.
- **Duplicates.** The later writer leaves an id the earlier one stored, and so stores
each id once. With `skip_duplicates=False` such an id is skipped without an error, as
an id already stored is today (ITL-1386).
each id once. ITL-1386 refuses an id visible at add time in strict mode. A key
committed by another writer after the add-time check is still skipped at flush.
- **Backticks.** delta-rs cannot MERGE a table with a top-level column whose name holds
a backtick, so such a column is refused (ITL-1375).

Expand Down
23 changes: 23 additions & 0 deletions docs/dev/design_issues/ITL-1386-WK1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## `src/orcapod/databases/`

### WK1 — A strict add accepts an already stored record ID
**Status:** resolved
**Severity:** high
**Issue:** ITL-1386

A strict add of an already stored ID was silently skipped by Delta and silently
replaced the row in memory and connector-backed stores. All three refused an ID
that was already in the pending batch.

**Fix:** Check stored IDs when adding, along with the pending IDs, and reject the
entire add if any conflict. The write-if-missing option still skips duplicates.
Writable connectors look up only the incoming IDs by primary key.
SQLite keeps its existing conflict policy for unique constraints on other columns.
Delta reuses the loaded table and ID snapshot when the log has not advanced.
Delta compares extension IDs by their Arrow storage values on both the writing
handle and reopened handles, including extension IDs stored as lists or structs.
Delta refuses an add whose nested ID storage type differs from the pending or
stored ID type, before schema handling can change the ID.
Arrow's primitive comparison preserves values outside Python's date range.
Delta streams the MERGE for nested IDs so a batch that loses to a committed row
can still flush and insert any distinct IDs it holds.
24 changes: 24 additions & 0 deletions docs/dev/design_issues/ITL-1415-WK3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## `src/orcapod/databases/`

### WK3 — Appends accept changed field metadata inside extension storage
**Status:** resolved
**Severity:** high
**Issue:** ITL-1415

The append check skipped the nested fields of extension types. An append could
carry different field metadata inside a struct-backed extension and read back
with the held column's metadata.

**Fix:** Compare field metadata recursively in extension storage. Delta checks
the metadata held in its log against the incoming storage fields before enqueue
and also checks against the version loaded for a commit.
Nested logical identifiers are checked separately from ordinary field metadata.
When IPC exposes an unregistered whole-column extension as storage with an
Arrow annotation, Delta refuses conflicting metadata explicitly present on
corresponding struct fields of both sides and treats missing attributes as
unknown. Delta refuses extensions nested inside another type (ITL-1372).

The Delta log has no field metadata for list items or map keys and values
inside extension storage. For committed rows, those annotations are unknown.
The initial Parquet footer can carry list item metadata, while later MERGE
footers can omit it.
12 changes: 12 additions & 0 deletions docs/dev/design_issues/ITL-1444-WK4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## `src/orcapod/databases/delta_statistics.py`

### WK4 — Delta file statistics on typed record IDs can let concurrent commits miss an overlap
**Status:** resolved
**Severity:** high
**Issue:** ITL-1444

Statistics on non-binary record IDs could let Delta file skipping hide a conflict
when two handles committed the same new ID.

**Fix:** Exclude the record ID from every new table's statistics configuration.
Existing table properties are retained.
13 changes: 13 additions & 0 deletions docs/dev/design_issues/ITL-1487-WK2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## `src/orcapod/databases/connector_arrow_database.py`

### WK2 — A second connector commit replaces the first writer's row
**Status:** resolved
**Severity:** high
**Issue:** ITL-1487

Two connector-backed database handles could queue the same new ID, then commit
different values. The last flush replaced the first writer's row when adding
with the default duplicate policy.

**Fix:** Use the connector's insert-if-missing operation at commit in both modes.
A conflicting ID visible at add time is refused in strict mode.
6 changes: 4 additions & 2 deletions src/orcapod/core/result_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,17 @@ def store(
output_data: The computed output data to store.
variation_datagram: Function variation metadata as a Datagram.
execution_datagram: Execution environment metadata as a Datagram.
skip_duplicates: If True, silently skip if a record with the
same ID already exists.
skip_duplicates: If True, skip a record with the same output UUID
already pending or stored.
data_context_key: Key of the caller's data context, stored on the row.

Raises:
InputValidationError: If a source-info token column of ``output_data``
is not a ``large_string`` (``RESULT_TOKEN_COLUMN``) or names no
output of ``output_data``; nothing is written. An output with no
token column is stored with a null token.
OrcapodDatabaseWriteError: If the database refuses the write, including
when the output UUID already exists and ``skip_duplicates=False``.
"""
require_same_data_context(input_data.data_context_key, data_context_key)
require_same_data_context(output_data.data_context_key, data_context_key)
Expand Down
18 changes: 18 additions & 0 deletions src/orcapod/databases/_sql_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def create_table_if_not_exists(
"""Create a record table in the verified schema."""
...

def existing_record_ids(
self, table_name: str, id_column: str, ids: set[bytes], *, schema: str
) -> set[bytes]:
"""Return the supplied record IDs currently present in the verified table."""
...

def upsert_records(
self,
table_name: str,
Expand All @@ -79,6 +85,18 @@ def upsert_records(
"""Write rows to the record table in the verified schema."""
...

def insert_store_records(
self,
table_name: str,
records: pa.Table,
id_column: str,
*,
skip_duplicates: bool,
schema: str,
) -> None:
"""Insert rows into the verified table, skipping IDs won by another writer."""
...


def catalog_name_pattern(name: str) -> str:
"""Escape a physical name prefix for a SQL LIKE expression with escape '!'."""
Expand Down
Loading
Loading