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

Support for custom incremental strategies #753

Open
mcowart123 opened this issue Jul 31, 2024 · 3 comments
Open

Support for custom incremental strategies #753

mcowart123 opened this issue Jul 31, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@mcowart123
Copy link

Describe the feature

Adding support for Custom Incremental Strategies.

Who will this benefit?

This will allow users to easily modify the MERGE command to take into account additional data from the table_changes function (for example)

merge into {{ target }} as DBT_INTERNAL_DEST
      using {{ source }} as DBT_INTERNAL_SOURCE
      on {{ predicates | join(' and ') }}
      when matched and DBT_INTERNAL_SOURCE._change_type = 'update_postimage' then update set {{ get_merge_update_set(update_columns, on_schema_change, source_columns) }}
      when not matched and DBT_INTERNAL_SOURCE._change_type != 'delete' then insert {{ get_merge_insert(on_schema_change, source_columns) }}
      when matched and DBT_INTERNAL_SOURCE._change_type = 'delete' then delete
@mcowart123 mcowart123 added the enhancement New feature or request label Jul 31, 2024
@benc-db
Copy link
Collaborator

benc-db commented Jul 31, 2024

Do you have some idea what is preventing custom incremental strategies?

@mcowart123
Copy link
Author

mcowart123 commented Aug 2, 2024

When I tried adding one dbt run failed with the following (I named the custom strategy merge_table_changes):

Invalid incremental strategy provided: merge_table_changes
      Expected one of: 'merge', 'replace_where', 'append', 'insert_overwrite'

Looking at a similar issue reported here it seems this is the response when custom strategies aren't supported; dbt-databricks itself is called out in that response.

Another issue here is similar and that is talking about if there's not an adapter macro to get your custom strategy macro it will fail.

@benc-db
Copy link
Collaborator

benc-db commented Aug 2, 2024

Thanks for detail; I don't see any particular reason to block this, so when I get some time I'll look into what it would take to support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants