-
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
Add non-destructive functionality to Snowflake table materializations #1972
Conversation
disallow 3.1.x, except for 3.1.1 which works fine
…schema Set a much more strict version upper bound for jsonschema
…ndency-issues Lock many dependencies/sub-dependencies (dbt-labs#1892)
Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA. In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin. CLA has not been signed by users: @liveandletbri |
I just signed the CLA |
I spoke with @beckjake and he recommended that I make this custom materialization. I'm all for that! Closing this PR then. |
hey @liveandletbri - thanks for opening this PR! Glad you got in touch with Jake - this is a neat PR, but it's not something I anticipate adding support for in dbt-core. I think a custom materialization is a really good idea here :) I did want to tell you that this PR compelled me to add some more info to our contributing guide for dbt. We want to be supportive of folks contributing code back to dbt, and I felt that our policies around how new features are contributed to the project were poorly specified. No action is required on your part here - just wanted to give you a heads up that this exists now :D |
Problem
Snowflake's time travel functionality is most easily usable when a table is not dropped and re-created every time it is refreshed. For incrementally-loaded models, this is fine. The table is only dropped when we perform a full refresh. But for
materialized: table
models, this is an issue, since these tables are dropped regularly (for us, many of them are dropped hourly).Time travel is very useful for troubleshooting, as it allows you to see exactly what data a table contained at an exact time. However, each time the table is dropped, the "time travel history" starts over at that point. I cannot query a table's contents from 12:15 PM if it was dropped and re-built any time between then and now. Well, not easily.
Snowflake can show you a table's history using the
show tables history
command. For a table refreshed hourly, you might see something like this:It's currently 3:45PM. To find what the data looked like for
my_table
at 12:15 PM, I would have to do this:Solution
By adding the non-destructive functionality back, tables can be preserved so investigation is as easy as this:
I know that the
--non-destructive
flag was removed in 0.14.0 (#1419), but I'm hoping this version of its functionality will be easier to maintain for the following reasons:delete
instead oftruncate
to avoid auto-committing the transactionQuestions
As a first-time contributor to DBT, I do have a few questions
delete
explicitly rather than adding a functionality to the adapter, so I could write{{ adapter.delete_relation }}
? I saw the existing file already usedinsert
explicitly, and here's another file that usesdelete
explicitly.create_table_as
call. I can see it in the core table file, though. How does DBT know, when I run my refreshes against Snowflake, to use this logic?