Add DML table refresh method for table materializations (#641).#673
Merged
axellpadilla merged 1 commit intoMay 20, 2026
Merged
Conversation
Adds an opt-in `table_refresh_method` model config: - `'rename'` (default): unchanged rename-swap behaviour. - `'dml'`: builds new data into a scratch table, then DELETE + INSERT into the target inside an explicit BEGIN/COMMIT TRANSACTION. Under RCSI, the DML path keeps the target name resolvable throughout the swap so concurrent readers see the old data until COMMIT. The scratch table is built via a temp view so CTEs in the model SQL work, and the INSERT uses the target's physical column order so a reordered SELECT projection cannot misalign columns. Schema changes fall back to rename-swap for the affected run; the DML path also falls back when the existing relation is a view (DML cannot operate on views). Adds functional coverage for first run, subsequent run, schema-change fallback, default vs explicit method config, invalid method validation, clustered columnstore preservation, contract enforcement, models with CTEs, view-to-table migration, column-order divergence, empty models, and leftover-scratch cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an opt-in
table_refresh_methodmodel config:'rename'(default): unchanged rename-swap behaviour.'dml': builds new data into a scratch table, then DELETE + INSERT into the target inside an explicit BEGIN/COMMIT TRANSACTION.Under RCSI, the DML path keeps the target name resolvable throughout the swap so concurrent readers see the old data until COMMIT. The scratch table is built via a temp view so CTEs in the model SQL work, and the INSERT uses the target's physical column order so a reordered SELECT projection cannot misalign columns. Schema changes fall back to rename-swap for the affected run; the DML path also falls back when the existing relation is a view.
Fixes #641