Use intermediate-and-swap pattern in full-refresh incremental path#398
Open
sdebruyn wants to merge 1 commit into
Open
Use intermediate-and-swap pattern in full-refresh incremental path#398sdebruyn wants to merge 1 commit into
sdebruyn wants to merge 1 commit into
Conversation
The full-refresh branch of fabric__incremental dropped the existing target before re-creating it. If the subsequent CREATE TABLE AS SELECT failed for any reason — transient Fabric error, query timeout, broken model SQL, capacity throttling, OOM, network hiccup — the user was left with no target table at all. Build the new table into an intermediate relation first, then rename the existing target to a backup, rename the intermediate to the target, and drop the backup. If the build fails, the existing target stays in place. This is the same pattern dbt-postgres, dbt-snowflake, and dbt-spark use.
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.
Fixes #397.
The full-refresh branch of
fabric__incrementaldropped the existing target before re-creating it, so a transient Fabric error, query timeout, capacity throttling event, OOM, or network hiccup during the CTAS step left the user with no target table at all. Downstream BI dashboards and reports point at nothing until the next dbt run completes successfully.Change
Adopt the intermediate-relation + backup-and-swap pattern that dbt-postgres, dbt-snowflake, dbt-spark, and dbt-bigquery use:
make_intermediate_relation(target_relation)). If this fails, the existing target stays untouched.Leftover intermediate / backup / temp-view relations from a previous failed run are dropped before the build, matching the existing cleanup pattern.
Testing
Happy to extend the change with an integration test that injects a CTAS failure during
--full-refreshand asserts the previous target is still queryable, if that's the preferred follow-up.