-
Notifications
You must be signed in to change notification settings - Fork 976
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
User-defined custom incremental strategies #4716
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9f53cff
User-defined custom incremental strategies
dbeatty10 7768ec5
Example of a custom incremental strategy
dbeatty10 0efb82d
Using custom strategies from a package
dbeatty10 f581838
Remove curlies
dbeatty10 63104c9
Add an example file name
dbeatty10 ea15804
Fix link
dbeatty10 17d7838
Merge branch 'current' into dbeatty/custom-incremental-strategies
mirnawong1 3689f47
Merge branch 'current' into dbeatty/custom-incremental-strategies
mirnawong1 ebff49a
Merge branch 'current' into dbeatty/custom-incremental-strategies
mirnawong1 e78ffec
Merge branch 'current' into dbeatty/custom-incremental-strategies
mirnawong1 e9a0422
Merge branch 'current' into dbeatty/custom-incremental-strategies
mirnawong1 59345e4
Update incremental-models.md
mirnawong1 f5579f9
Update website/docs/docs/build/incremental-models.md
mirnawong1 285915a
Update website/docs/docs/build/incremental-models.md
mirnawong1 89bc5e1
Update incremental-models.md
mirnawong1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
are we saying the macro should always be named
get_incremental_STRATEGY_sql
?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.
or is
STRATEGY
a placeholder? if its a placeholder, we should maybe be more clear on that.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.
Yep,
STRATEGY
is a placeholder!Any ideas how to make it more clear?
Along the lines of your suggestion about the table, you think adding adding it would make it more clear?
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.
ok gotcha, thank you for clarifying! waht do you think about the following suggestion @dbeatty10 :
Built-in strategies and their corresponding macros
Before diving into custom strategies, it's important to understand the built-in incremental strategies in dbt and their corresponding macros:
incremental_strategy
append
get_incremental_append_sql
delete+insert
get_incremental_delete_insert_sql
merge
get_incremental_merge_sql
insert_overwrite
get_incremental_insert_overwrite_sql
For example, a built-in strategy for the
append
can be defined and used with the following files:Define a model models/my_model.sql:
Custom strategies
Custom incremental strategies can be defined beginning in dbt v1.2.
As an easier alternative to creating an entirely new materialization,
users can define and use their own "custom" user-defined incremental strategies by:
get_incremental_STRATEGY_sql
. Note thatSTRATEGY
is a placeholder and you should replace it with the name of your custom incremental strategy.incremental_strategy: STRATEGY
within an incremental modeldbt won't validate user-defined strategies, it will just look for the macro by that name, and raise an error if it can't find one.
For example,.....
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.
ok @dbeatty10 proposing the above adn before i make the changes or sugg - please let me know if that makes sense to you 🙏
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.
This looks good 🚀
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.
ok cool, will make that change!