Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #376
rezasoltanirezvandeh opened this issue Jun 5, 2022 · 6 comments
Closed
Tracked by #376

Comments

@rezasoltanirezvandeh
Copy link

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" );

@dataders
Copy link
Collaborator

dataders commented Jun 5, 2022

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

@rezasoltanirezvandeh
Copy link
Author

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

@hernanparra
Copy link

Same problem here on SQL Server 2017 with dbt 1.0.4 and sqlserver 1.0.0

@hernanparra
Copy link

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: dbt-labs/dbt-core#5260 (comment)

@hernanparra
Copy link

The team of dbt-core did the refactoring in version 1.3. Is the incremental "merge" strategy working now?

@openfarma
Copy link

I think this bug has solved. Now the incremental strategy is using merge by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants