Repository navigation
Description
Once a Delta source can be materialized (#2161), every poll would be a full read of the table. Iceberg avoids that two ways (ScanChoice in fluree-db-api/src/graph_source/r2rml.rs):
- an added-files scan when the window is append/replace only;
- a fallback to a full read when the window contains an overwrite or delete.
Delta offers something better than either: the change data feed. fluree-db-delta has no reader for it today.
Kernel already has the reader
delta_kernel 0.28, which fluree-db-delta/Cargo.toml already pins, ships delta_kernel::table_changes::TableChanges:
TableChanges::try_new(table_root, engine, start_version, end_version)plus a scan builder.- Rows come back with three extra columns:
_change_type:insert,delete,update_preimageorupdate_postimage;_commit_version;_commit_timestamp.
- A commit's changes are read from its
_change_datafiles if it wrote any, and otherwise derived from itsadd/removeactions. - Kernel requires
delta.enableChangeDataFeedto stay on across the whole range, and the schema to be equal across it. - There is also a row-tracking listing mode (
try_new_row_tracking_cdf_listing, withNetChanges) that needsdelta.enableRowTrackinginstead.
Proposal
1. Reader. Add DeltaTable::changes(from_exclusive, to_inclusive) -> DeltaBatchStream over TableChanges. It yields ColumnBatches that carry the three metadata columns.
2. Window choice. Mirror ScanChoice, and log which case fired:
- change feed, when it is enabled across
(from, to]; - else an added-files scan, when the window holds only
addactions; - else a full read.
3. Mapping changes onto the materializer.
- Latest-by-key mode:
insertandupdate_postimageare row images;deleteis a tombstone that retracts the subject;update_preimageis skipped;- ranking is by
_commit_version, ahead of any configuredorder_by.
- Additive mode: a
deletehas no counterpart today, because additive passes never retract. Decide whether a change-feed delete retracts the row's triples, or whether additive mode keeps ignoring deletes as it does for Iceberg.
4. Per-pass bound. Cap the version range with commit-level row counts, where commitInfo.operationMetrics has them, the way Iceberg's cap_window_by_rows uses snapshot summaries. Commits are Delta's natural checkpoint.
Failure modes to handle explicitly
- The change feed was off for part of the window: Kernel errors. Fall back to a full read, and log why.
- The schema changed inside the window: Kernel requires equality. Split the window at the change, or fall back.
fromhas fallen out of log retention: full read. This is the Delta equivalent ofFullUndeterminable.
Depends on #2161.
Activity