question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incremental Strategy "Merge" is generating Delete, Insert into command

See original GitHub issue

Merge strategy in incremental, generates delete and insert into command instead of the merge.

{{ config( as_columnstore= false, materialized= 'incremental', incremental_strategy= 'Merge', unique_key='customer_code' ) }} SELECT customer_code, customer_name FROM {{ref('customer')}}

The run script: delete from "......."."dim_customer" where (customer_code) in ( select (customer_code) from "......."."#dim_customer__dbt_tmp" ); insert into "......."."dim_customer" ("customer_code", "customer_name") ( select "customer_code", "customer_name" from "......."."#dim_customer__dbt_tmp" );

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
rezasoltanirezvandehcommented, Jun 5, 2022

Hi @dataders,

here are the details:

_(base) reza@dbt:~/Desktop$ dbt --version installed version: 1.0.7 latest version: 1.1.0 Your version of dbt is out of date! You can find instructions for upgrading here: https://docs.getdbt.com/docs/installation Plugins:

  • sqlserver: 1.0.0 - Up to date! (base) reza@dbt:~/Desktop$_

and I am using Azure SQL Database. Cheers, Reza

1reaction
hernanparracommented, Jun 13, 2022

I checked the dbt-core sources and the “get_merge_sql” macro isn’t called on project. Some official adapters reimplement the incremental materialization and use that macro. I don’t know if the effort to support this is gonna pay, as by this comment, they’re planning to refactor all the materialization code: https://github.com/dbt-labs/dbt-core/issues/5260#issuecomment-1132871807

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding dbt Incremental Strategies part 1/2 - Medium
The delete+insert strategy is very similar to merge, but instead of updating existing records and insert new records, it deletes existing records and...
Read more >
Incremental models - dbt Developer Hub
On warehouses that do not support merge statements, a merge is implemented by first using a delete statement to delete records in the...
Read more >
Implement a delete+insert incremental_strategy for Google ...
As an alternative, we have to define a unique_key based on multiple columns. This wouldn't work for cases where the source for the...
Read more >
How do we use the merge statement inside Incremental model ...
You don't actually need to write the merge statement, dbt will take care of that for you. You should write a query that...
Read more >
Incremental load of the data warehouse using Merge vs ...
1) MERGE command. Update when there is a Match; Insert when Not Match · 2) DELETE+INSERT. Delete rows from the Target table where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found