Fix adapter macro namespacing (#2548) #2590
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #2548
Description
Fix adapter macros so they can override core (and one another) in consistent ways.
Generally, macros from plugins that aren't actively in use are no longer available, and macros follow a name resolution hieirarchy within
dbt
: dbt-global-project macros have a lower precedence than dependency plugins have a lower precedence than the current plugin. If the adapter type is unknown, dbt loads all the plugins it knows about in an undefined order, except that the internal global project is guaranteed to have the lowest priority.To make this effective without doing tons of imports inside functions/methods, I had to refactor a bit. Some functions moved out of
dbt.utils
to remove its dependencies, and some base type definitions moved fromadapters
intocontracts
. I also (finally) moved node runners into their non-rpc tasks, which allowed me to move some common logic intodbt.task
, and consolidateddbt.ui.*
into a singledbt.ui
.Most of these changes are rewritten imports and files moved. The changes that require the most attention are the changes to
adapter/factory.py
(plugin loading, path determination) andcontext/configured.py
(macro resolution)This does not convert
adapter_macro
into a python function, but I think it should make it unnecessary.Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.