-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
is_incremental() macro should return false when the target relation is not "incremental" #1249
Comments
Hey @davehowell - You're right that the Can you tell me a little bit more about behavior you're interested in seeing here? I'm not sure I totally understand who the intended benefactor of changing the |
Thanks for quick response Drew. The docs suggest starting out with all models as views, and then later changing to table or incremental as required, which makes total sense. I've started to do that, adding an The consequence is I have a view with an incremental block If writing code that uses Maybe it's just me that's confused, and I have workarounds available. I can comment-out the incremental block until actually switching it to incremental, and I can use a different custom macro to get the behaviour I expected. |
I've thought some more and it seems the intention is that it will ignore the `is_incremental()' block and do a full refresh either the very first time the model is deployed, or if the user explicitly asks to do a full refresh, and the existing code does do that. The behaviour I expect though is that it honours the config.materialized setting. I'm using this custom macro to achieve that.
ps) I notice there's already a nice protection against accidentally dropping a table if you are going from incremental/table --> view in the |
Thanks for the additional info @davehowell. Check out the previous discussion over here: #744 I think you're right, the name
so I was a little opposed to picking a macro name like:
and instead was relatively happy with Last thing to say about this: dbt allows users to override (or define their own) materializations. As such, I have a great opposition to hard-coding the name of a dbt materialization in a macro like this. Imagine you wrote a custom materialization that slightly modifies the So, all in all, I think what you're asking for is reasonable, but there are really tiny reasons why I'm not super bullish on making this change now. Happy to leave this issue open so other interested folks can agglomerate their opinions here. Thanks! |
Thanks for your considered response. Overriding the built in materializations would be a recipe for confusing others used to the standard dbt behaviour, but assuming I did and named it 'incremental' then it would be my fault if it then didn't cooperate with the built in macros. If I wrote a custom materialization it would be reasonable to expect that it may not work with built in macros like is_incremental. I see your point about avoiding the longer name for it, although it kind of already does have the name of a materialization hardcoded into the name of the macro itself so makes it hard to separate the two concepts. I'm happy with my workaround, and as you've said the behaviour hasn't changed so other users will already be used to it. Avoiding impact to them is the best reason not to change it, so I'm happy to close this. Reminds me of this.
|
Had a chat with at-samk in the dbt Slack. This is probably a change worth making! Custom materialization implementers can handle this in a multitude of ways -it's ok to hard-code the |
Oh nice, and I see #1292 implements what I first suggested in this issue. I agree with "someone who goes through all the trouble of implementing a custom materialization could override the I think implementing a custom materialization is a lot more complex than just making a new macro or overriding it. |
FYI: This is implemented in #1608 Should be going out in 0.14.1 |
If the
is_incremental()
macro is used to write a SQLwhere
clause, it doesn't really make sense to apply thatwhere
clause when the deployed model is aview
. Or does it? I can't think of the use case.The docs on understanding the is_incremental() macro also state that this applies to a destination
table
, not mentioning that it applies to aview
:I propose a small modification to change this line:
https://github.com/fishtown-analytics/dbt/blob/3b0d14bd5d5805da10835fa522368152e048b4cd/core/dbt/include/global_project/macros/etc/is_incremental.sql#L8
To this
return(relation.type == relation.Table and not flags.FULL_REFRESH)
The relation should not only exist, it should be a table.
The text was updated successfully, but these errors were encountered: