You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible to call adapter.dispatch for materialization macros, and return the appropriate macro for this adapter, which can then be called/executed from within another macro/materialization
In conversation with Kshitij just now, it seems that the main changes need to be in core/dbt/context/macros.py, in MacroNamespace.get_from_package where we can add special processing of "materialization" macros. The "get_from_package" method is called from adapter.dispatch, which comes from the adapter "contextproperty" of the ProviderContext in core/dbt/context/providers.py. The actual "dispatch" method is in the BaseDatabaseWrapper.
The materialization macro can be found in the "execute" method of the clone task (and probably the same method in runnable.py) by doing context.adapter.dispatch from the constructed context. This should already be a MacroGenerator callable, so we wouldn't need to construct a MacroGenerator as we do further down in "execute".
This would constitute a new way of calling materialization macros with a different method of inheritance. There's also some complexity in that materialization macros can have parameters that don't exist in "normal" macros which would need to be handled.
Definition of done:
adapter.dispatch
for materialization macros, and return the appropriate macro for this adapter, which can then be called/executed from within another macro/materializationIn conversation with Kshitij just now, it seems that the main changes need to be in core/dbt/context/macros.py, in MacroNamespace.get_from_package where we can add special processing of "materialization" macros. The "get_from_package" method is called from adapter.dispatch, which comes from the adapter "contextproperty" of the ProviderContext in core/dbt/context/providers.py. The actual "dispatch" method is in the BaseDatabaseWrapper.
The materialization macro can be found in the "execute" method of the clone task (and probably the same method in runnable.py) by doing context.adapter.dispatch from the constructed context. This should already be a MacroGenerator callable, so we wouldn't need to construct a MacroGenerator as we do further down in "execute".
Originally posted by @gshank in #7799 (comment)
Motivation
This would enable us to refactor the implementation in the
clone
materialization here:dbt-core/core/dbt/include/global_project/macros/materializations/models/clone/clone.sql
Lines 49 to 58 in a58b5ee
It might also unblock an approach for this desirable UX improvement to model versions:
The text was updated successfully, but these errors were encountered: