-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow dispatch & overrides of global macros via packages #3456
Comments
Thanks for opening @clausherther, and for making such a clear statement of the problem. I agree with all the examples and use cases you've provided. To make it as pellucid as possible, there are two phenomena at play here:
We're talking about changing the behavior of the latter, but leaving the former in place. I think this might be as simple as going through the dispatch calls within the To go example by example:
This would continue to work exactly as it does today.
In order for this to work, the package would need to reimplement either
This would continue to work exactly as it does today, where the root One final note that came up in our Slack conversation: The way we've implemented the |
Also 💯 points for the (near) alliteration of "pellucid...possible...phenomena" |
Describe the feature
As a dbt package developer, I'd like to be able to override a built-in (global) macro like
create_table_as
oris_incremental
in a package and have projects that import the package transparently use the built-in macro without any changes to their code.One way to accomplish this would be to allow dbt to apply its package dispatch functionality to global macros.
@jtcohen6 has suggested the following syntax in this Slack thread.
This would effectively inject
my_package
in the dispatchsearch_path
for global macros in thedbt
project.It would also maintain the current behavior where dbt looks for overrides of global macros in the current root project and should follow the precedence described for materializations here.
So, e.g. if someone
create_table_as
locally in the root project only, dbt would use the local versioncreate_table_as
only, dbt would use the package version (over the global version)create_table_as
locally in the root project and imported a package that overwrotecreate_table_as
, dbt would use the local version in the root project, over the package version and over the global version.Another use case, in addition to overrides of the
default__
version of macros, would be for a package to supply alternate versions of global macros for specific platforms. Ideally such platform specific versions of global macros should belong in the respective plugin's global project, but there may be use cases for company-specific overrides to particular platforms that don't make sense in the plugin project.Describe alternatives you've considered
An alternative would be to wrap the macro exposed by the package locally. This would require project owners to be aware of the override and maintain a local wrapper macro for each override.
Who will this benefit?
This would benefit package maintainers, particular those maintaining internal, company specific packages that override default behavior with customized implementations.
The text was updated successfully, but these errors were encountered: