Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DBT for BigQuery - Why is there no delete+insert by a primary key?

This is more of a theoretical question: I have a scenario where I wish to do a delete + insert from a source table to a target table in DBT. (Match by PK, delete existing records then insert).

DBT doesn't seem to support this incremental strategy for BigQuery (It does for Snowflake).

It instead offers an insert+overwrite by deleting and re-inserting a given partition. Which doesn't solve my specific need.

Is there a reasoning behind this?

like image 882
Dina Kleper Avatar asked Dec 05 '25 20:12

Dina Kleper


1 Answers

I think you want merge, which should accomplish the same as a delete and insert, but with better performance. BQ docs on merge statements.

delete+insert is only supported for Snowflake to support an edge case where the PK of the table is not actually unique. source. On Snowflake merge is also preferred/more performant.

like image 101
tconbeer Avatar answered Dec 08 '25 13:12

tconbeer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!