-
Notifications
You must be signed in to change notification settings - Fork 179
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
[ADAP-432] [Feature] Snowflake Adapter supports INSERT OVERWRITE #550
Comments
Hey there! I'm still trying to understand the scope of work here. Is the ask to add a model config applicable to table and incremental only, to indicate that This would mean that normal runs for table, and full-refresh runs for both table and incremental would be impacted? |
My understanding is that this would be best as a new incremental strategy incremental_strategy: insert+overwrite +1 for this feature! |
Hi @adammarples - can you please tell me more? The adapters where we support an |
@Fleid It would be better named if it weren't listed as incremental, but some of the other behaviors of table materialization such as potentially dropping / replacing the table are to be avoided for INSERT OVERWRITE. |
@markproctor1 I think we agree here. There is value, but not limited to incremental models. So it's not an incremental strategy, but rather an overall switch to make all drop/replace operations replaced by |
@Fleid What goes into the decision to make it a switch rather than an optional part of table materialization? Someone out there probably LOVES the fact that their tables get dropped :) |
I think I covered the fact that it was not a strategy for incremental models. Could it be a materialization by itself? Materializations are about the type of object being created in the database. We have views, tables, CTEs (ephemerals), and soon materialized views. The only exception is incremental models, which do generate tables, but needed to be clearly delineated from tables as the handling mechanism is widely different. This is me post-rationalizing, because I wasn't there for that decision, but I'm glad it's not a switch on tables. Is using |
This is intuitive to me: However, "insert overwrite" as a concept can be full load or incremental: https://docs.getdbt.com/reference/resource-configs/glue-configs#the-insert_overwrite-strategy
So there's concept disagreement, the term can mean both table and incremental outside of dbt. In Snowflake, it means materialized=table. |
Since you already have some code there, would you be interested in contributing a PR? |
@Fleid yes my mistake, it would be a table materialization, not an incremental strategy |
@Fleid I'm trying to decide when to fit this in, as sprint work or on the side. I am interested, will get back to you asap. |
This is probably how seeds should work, on Snowflake, instead of This makes less sense to me for incremental models (since it always replaces the full contents, unless partition-based |
@jtcohen6 Your comment makes sense about seeds, but I don't know enough to say whether it should be in scope here. Regarding table models: Do you expect What is the dbtonic of resolving target table changes not handled by the specified materialization? If it were incremental and the target object is no longer compatible it would just error right? |
Like discussed, I would not be clever. If we limit the scope of |
@Fleid Our teams are discussing this again. We're finding the benefit of INSERT OVERWRITE in our custom materialization isn't worth the extra dev/maintenance time through table schema changes. So as you say, it would be best to have --full-refresh. @dataders I'm not sure this is incremental, in the sense of incremental materialization, as we've discussed it. |
@markproctor1 my read here is that you and your team no longer think that inclusion of Snowflake's |
@dataders No, I was unclear! We want it more than ever but think it should be handled as a table materialization instead of an incremental materialization. |
@markproctor1 do you care to open a PR that modifies the existing table materialization? I think that'd make this discussion much more focused. |
Hello, is this still in progress or are there any plans for this? key feature here is using the underlying time travel feature which gets lost when we drop/replace tables. |
Checking on the status of this. Did the INSERT OVERWITE concept get moved to a different PR? |
I don't know whether it moved to a different PR; I ran into some design decisions over the months. Snowflake Insert Overwrite
We still use Matt Winkler's custom materialization for all our most important work, but I don't know how to design this. |
Could this be an incremental strategy within the incremental materialization instead of an option in table? Might be a simple way to implement this? There's even schema change logic already a part of the incremental materialization. Edit: sorry I saw this was discussed somewhat. In terms of it needing to be a table or incremental. What's the difference between it as a new incremental strategy versus a table option with full refresh set to false? |
Is this issue still open ? Do we have a workaround for INSERT OVERWRITE in dbt |
I also support this change whichever way it's implemented |
Is this your first time submitting a feature request?
Describe the feature
Snowflake has an optional parameter for inserts which does TRUNCATE behavior before INSERT. It's one transaction and avoids dropping or recreating tables.
https://docs.snowflake.com/en/sql-reference/sql/insert#optional-parameters
INSERT [ OVERWRITE ] INTO <target_table>
Support this feature in dbt
Describe alternatives you've considered
There is no single-transaction alternative feature to TRUNCATE / DELETE * and then INSERT. This is documented by Snowflake.
Who will this benefit?
Anyone who needs to avoid DROP/RECREATE and at the same time wants to full load will benefit, with the added bonus of keeping the behavior single-transaction.
In our use case, we don't want tables to be dropped as the table has permissions and policies which need to be kept in place despite which process is doing the load. At the same time, the rows of the table are completely replaced during load.
Are you interested in contributing this feature?
Yes, I need to understand materializations better but in my naivete this seems like a simple and valuable feature
Anything else?
Matt Winkler already built this:
(https://github.com/matt-winkler/dbt_workspace/blob/master/dbt/macros/materializations/snowflake_custom_incremental/insert_overwrite.sql)](https://github.com/matt-winkler/dbt_workspace/tree/master/dbt/macros/materializations/snowflake_custom_incremental)
The text was updated successfully, but these errors were encountered: