How do I override the default insert/delete behavior with incremental tables in Postgres? #2293
gvashishtha
announced in
Archive
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a dbt model that populates a table, foo. foo has a column, id, that is referenced as a foreign key by a different table, bar.
Sometimes my upstream data source changes a different column of foo, baz. I'd like to be able to update the value of foo.baz without changing the value of foo.id, so that my end users see up-to-date data about foo. Unfortunately, Postgres throws an error during dbt's default "delete then insert" strategy because I can't delete a foreign key from foo that's referenced by bar.
I found a GitHub issue that stated I had to create a macro called "incremental_upsert" to override the default behavior with a custom "ON CONFLICT DO UPDATE" function. Unfortunately, this PR seems to have gotten rid of that macro. I'm now not sure how to override dbt's default incremental strategy.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions