-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature: support for arbitrary predicates for incremental models #4546
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{# | ||
|
||
These macros will compile the proper join predicates for incremental models, | ||
merging default behavior with the optional, user-supplied incremental_predicates | ||
config. | ||
|
||
#} | ||
|
||
{% macro get_incremental_predicates(target_relation, incremental_strategy, unique_key, user_predicates, partitions=none) %} | ||
{{ adapter.dispatch('get_incremental_predicates')(target_relation, incremental_strategy, unique_key, user_predicates, partitions) }} | ||
{% endmacro %} | ||
|
||
{% macro default__get_incremental_predicates(target_relation, incremental_strategy, unique_key, user_predicates=none, partitions=none) %} | ||
{# | ||
|
||
This behavior should only be observed when dbt calls the default | ||
`get_delete_insert_merge_sql` strategy in dbt-core | ||
|
||
#} | ||
{%- if user_predicates -%} | ||
{%- set predicates %} | ||
{%- for condition in user_predicates -%} and {{ target_relation.name }}.{{ condition.source_col }} {{ condition.expression }} {% endfor -%} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason to call the parameter I'd expect something like |
||
{%- endset -%} | ||
{%- endif -%} | ||
|
||
{{ return(predicates) }} | ||
|
||
{% endmacro %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean incremental predicates will only work for delete+insert strategy? is this just to get the feature started with least amount of work, or is there a blocker to implement for the merge strategy?
I don't exactly have an exact use case to share, so just curious and generally thinking about pros/cons of moving from merge to delete+insert strategy.