Skip to content

fix(delta): start CDF at the first DLT SETUP since the last full refresh - #184

Open
haillew wants to merge 1 commit into
mainfrom
fix/starting-version-from-dlt-setup
Open

haillew wants to merge 1 commit into
mainfrom
fix/starting-version-from-dlt-setup

Conversation

@haillew

@haillew haillew commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

startingVersionFromDLTSetup set the CDF startingVersion to the latest DLT SETUP in the source table's history. A normal update also writes DLT SETUP whenever the table definition changes, such as a table property or schema change. So the latest one can sit after data the table still holds. A reader with no checkpoint then silently skips that data, with no error. For example, this happens to a downstream table that is fully refreshed on its own, or one whose first run after a reset is interrupted.

Changes:

  • SourceDelta now starts at the first DLT SETUP at or after the latest DLT REFRESH (the commit a full refresh writes). If the table was never fully refreshed, it uses the earliest DLT SETUP. The logic is in a small helper, resolve_starting_version_from_history().
  • The startingVersionFromDLTSetup docs now describe the rule. They also note that tables reading the source's CDF must be fully refreshed with it, as the Databricks full refresh docs require.
  • Unit tests built from table histories recorded on a real pipeline.

Tested:

  • Unit and integration tests pass (458).
  • On a workspace, a framework pipeline: SCD1 staging table with CDF, read with starting_version_from_dlt_setup into a downstream table. The steps were first run, full refresh, a table property change, then a full refresh of only the downstream table. On main the downstream table ends up with 0 rows and no error. With this change it has all 4 rows.
  • The feature-samples run job passes against this build, and the historical_snapshot_files_flow sample (which uses this option) gives the same output as on main.
  • A plain SDP pipeline (no framework) confirmed the history this relies on:
    • A full refresh writes DLT REFRESH, SET TBLPROPERTIES, DLT SETUP, then data.
    • A definition change on a normal update writes another DLT SETUP with no data.
    • The DLT REFRESH commit holds a delete row for every previous row. Starting at the DLT SETUP after it means those deletes are never read.

This covers the main problem in #176. The issue's "second, related problem" did not reproduce in my plain SDP test: during a full refresh the view already saw the refresh's own commits. I'm still testing it with the issue's full cdc-stream-from-snapshot pattern, so this PR doesn't close the issue.

Refs #176

startingVersionFromDLTSetup set the CDF startingVersion to the latest
'DLT SETUP' in the source table's history. A normal update also writes
'DLT SETUP' whenever the table definition changes, so the latest one can
sit after data the table still holds. A reader with no checkpoint (e.g. a
downstream table that is fully refreshed on its own) then silently skips
that data.

The starting version is now the first 'DLT SETUP' at or after the latest
'DLT REFRESH' (the commit a full refresh writes), or the earliest
'DLT SETUP' if the table was never fully refreshed.

Refs #176

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant