-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
include project macros in the manifest the adapter stores locally #2686
Conversation
@drewbanin this fixes an issue I bet exists in the 0.17.x RPC server as well: if you change a config and reload, it won't be reflected on the adapter level. I think that means quoting changes in |
bf7b1ef
to
398aeb9
Compare
Make sure "dbt deps" reloads the full manifest Make sure commands that reload the dbt_project.yml properly reset the config (including adapters)
398aeb9
to
4274139
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This works as I'd expect.
Following on from the dispatch
work, I decided to try something: If I'm running on postgres, and define in my local project:
get_columns_in_relation
: overridespostgres__get_columns_in_relation
: overridesdefault__get_columns_in_relation
: does not override
That's true whether I call it as {{ get_columns_in_relation }}
or {{ adapter.get_columns_in_relation }}
. I'm fine with this behavior, as long as it doesn't surprise you.
Yeah. I don't think it's what I would dream of, but I also think it's probably one of the least-bad solutions right now. If you define a macro with the name, dbt will just look that up ( If you've defined This is all a consequence of the fact that adapter-specific macros are just regular macros + how dbt builds the context. I think the way to get this to behave how you'd expect is to have the adaptertype part of the macro definition (like materializations), and not put adaptertype macros into the context. In that world, The takeaway here from a behavioral perspective is: don't try to override the things |
Got it! Thanks for the explanation. It's much more important that this override be possible, from the root project, in one way or another. And indeed:
I don't see a need for packages to override adapter macros for use in the root project. As such, I don't feel passionately that we need all adapter macros to work with the level of rigor that materializations do. There may be a subset (e.g. schema tests) for which we decide it's necessary, someday, to wrap the adaptertype more tightly into the definition. |
resolves #2301
Description
Macros defined in core and called via the adapter's
execute_macro
method will now accept local overrides.Previously, if you wanted to override a macro in dbt that was used for internal purposes (listing schemas, creating schemas, dropping schemas, getting columns in a relation, ...), the only way to do so was in an adapter plugin itself. This is because the adapter uses a special internal manifest that doesn't require any non-macros. Previously, the adapter's internal manifest only looked at macros defined in dbt core and any active adapter plugins. Now, we search the entire project (including dependencies) for macros and use that for the manifest.
Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.