[CT-2581] [Feature] Allow for more flexible drop statements in drop_relation() #7625
Closed
3 tasks done
Labels
enhancement
New feature or request
Is this your first time submitting a feature request?
Describe the feature
The current implementation of
drop_relation()
looks like this:That forces a specific string for
relation.type
. In particular, it forces spaces inrelation.type
for some scenarios (e.g. materialized views) and it forces the dbt implementation of a model to match that of the underlying database. The latter is an issue if, as an example, dbt decides to implement "dbt materialized views" indbt-snowflake
by using dynamic tables. The issue in the end is thatrelation.type
is playing two roles that can't always be guaranteed to overlap.The proposal is to turn
drop_relation()
into a dispatch function and create functions such asdrop_table()
,drop_materialized_view()
, etc. There should still be a default condition indrop_relation()
in order to preserve backwards compatibility. The proposal would look something like this:Describe alternatives you've considered
An alternative would be to keep the current approach. This would mean creating dbt materializations that match the underlying database's implementation. In this scenario, there would be no materialized view implementation for
dbt-snowflake
because we implement that concept via dynamic tables. Likewise, there would be no dynamic table implementation for any other adapter besidesdbt-snowflake
.Another alternative is to overwrite
drop_relation()
for each adapter where necessary. That would address materialized view / dynamic table scenario since we could check for that in thedbt-snowflake
adapter. But that would encourage overwritingdrop_relation()
in general, which is a central macro (it gets used in almost every run). The goal of the proposal above is to allow adapter maintainers to configure how an object is dropped without the need to worry about dbt-level functionality (e.g. logging, how to implementcall statement
, etc.).Who will this benefit?
This will benefit adapter maintainers and
dbt-core
maintainers. Adapter maintainers can be more flexible with how they manage the drop logic while also being less concerned with breakingdbt-core
logic (or losing logic added in the future).dbt-core
maintainers can be more confident that any logic added in the future will be implemented while still allowing adapter maintainers a path for configuration.Are you interested in contributing this feature?
Yes
Anything else?
No response
The text was updated successfully, but these errors were encountered: