Skip to content

Delta ods hardening fixes#206

Merged
ealexa05 merged 4 commits into
mainfrom
delta-ods-hardening-fixes
Jul 6, 2026
Merged

Delta ods hardening fixes#206
ealexa05 merged 4 commits into
mainfrom
delta-ods-hardening-fixes

Conversation

@ealexa05

@ealexa05 ealexa05 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

This PR addresses some issues with the new delta pipeline (added here: #203), and puts a new test table on the gamma instance (EDW.USE_TRANSACTION).

  1. fix: Sparse updates no longer move rows to partition odin_year=0/odin_month=0
    The merge source derives odin_year/odin_month from the CDC batch's edw_inserted_dtm. When a sparse update batch carried no edw_inserted_dtm for a key, those degraded to 0 and were written verbatim. The row would silently move into the 0/0 partition (and out of partition-pruned query results) with internally inconsistent partition vs. data values. Partition columns now update via CASE WHEN source.edw_inserted_dtm IS NOT NULL THEN source.odin_year ELSE target.odin_year END, keeping the target's partition placement when the batch has no new timestamp.

  2. fix: Null header__change_seq CDC records now raise instead of being silently skipped
    The watermark filter header__change_seq > ? never matches NULL in SQL, so null-seq CDC records were excluded before the existing null_count == 0 assertion could see them. The documented "CDC records carry a change sequence" invariant was thus unenforceable. The CDC read now includes an OR header__change_seq IS NULL arm with ORDER BY … NULLS FIRST, so any null-seq record surfaces at the head of the next batch and fails loudly.

  3. fix: MERGE identifiers are quoted
    The MERGE key predicate and update/insert expressions used unquoted column names, so a column named like a SQL reserved word would break the merge. All column references in MERGE expressions are now quoted.

  4. fix: History reads scoped to the current snapshot partition
    Schema discovery previously ran DESCRIBE over the table-wide glob with union_by_name, unioning columns across every historical snapshot. A column dropped upstream would reappear in silver as a phantom all-null column. All reads now use a snapshot=/**/*.parquet glob (DuckDB's ** matches zero or more directories, and hive partitioning still derives the snapshot column). Side benefit: the job no longer lists/reads footers for every historical snapshot's files on each run. The WHERE snapshot = ? filters remain as defense-in-depth.

@ealexa05 ealexa05 requested a review from MaxAlex July 6, 2026 16:25
@ealexa05

ealexa05 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Merging for velocity test on dev

@ealexa05 ealexa05 merged commit c686d77 into main Jul 6, 2026
5 checks passed
@ealexa05 ealexa05 deleted the delta-ods-hardening-fixes branch July 6, 2026 21:37
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.

2 participants