dbt-sqlserver
dbt-sqlserver copied to clipboard
Incremental Strategy "Merge" is generating Delete, Insert into command
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" );
thanks for the bug report @rezasoltanirezvandeh ! can you share what version of dbt-sqlserver you are using as well as what SQL Server product you are using? Cheers
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
Same problem here on SQL Server 2017 with dbt 1.0.4 and sqlserver 1.0.0
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
The team of dbt-core did the refactoring in version 1.3. Is the incremental "merge" strategy working now?
I think this bug has solved. Now the incremental strategy is using merge by default.