Skip to content

Commit

Permalink
Explain how transactions (and rollbacks) are handled for incremental …
Browse files Browse the repository at this point in the history
…strategies (#4655)

[Preview](https://docs-getdbt-com-git-dbeatty-explain-incremental-957f61-dbt-labs.vercel.app/docs/build/incremental-models#how-do-incremental-models-work-behind-the-scenes)

## What are you changing in this pull request and why?

resolves #4635

The goal of this issue is to document the answer to this question from
dbt-labs/dbt-core#7011 (comment):

> For the DML, we know that only the delete+insert strategy will work,
and not merge. With delete+insert incremental strategy, does Dbt wrap
both in a single transaction? If not, and they are treated as 2 separate
transactions that would be bad. For example, the delete could succeed,
and the subsequent insert could fail. The table would then be left with
deleted records = Not Good. Can you elaborate on how Dbt already handles
that. I cannot find it anywhere in the doc.

### 🎩

<img width="600" alt="image"
src="https://github.com/dbt-labs/docs.getdbt.com/assets/44704949/6c398757-26a2-42c5-9783-8083ab7e20d0">


## Checklist

- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.

---------

Co-authored-by: mirnawong1 <[email protected]>
  • Loading branch information
dbeatty10 and mirnawong1 authored Dec 15, 2023
1 parent 96cf752 commit 203cb05
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion website/docs/docs/build/incremental-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ dbt's incremental materialization works differently on different databases. Wher

On warehouses that do not support `merge` statements, a merge is implemented by first using a `delete` statement to delete records in the target table that are to be updated, and then an `insert` statement.

Transaction management is used to ensure this is executed as a single unit of work.
Transaction management, a process used in certain data platforms, ensures that a set of actions is treated as a single unit of work (or task). If any part of the unit of work fails, dbt will roll back open transactions and restore the database to a good state.

## What if the columns of my incremental model change?

Expand Down

0 comments on commit 203cb05

Please sign in to comment.